28 lines
		
	
	
		
			459 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			459 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace App\Tests\Common;
 | 
						|
 | 
						|
use Faker\Factory;
 | 
						|
use Faker\Generator;
 | 
						|
 | 
						|
trait FakerTrait
 | 
						|
{
 | 
						|
    private ?Generator $faker;
 | 
						|
 | 
						|
    protected function bootFaker(): void
 | 
						|
    {
 | 
						|
        $this->faker = Factory::create();
 | 
						|
    }
 | 
						|
 | 
						|
    protected function getFaker(): Generator
 | 
						|
    {
 | 
						|
        if ($this->faker === null) {
 | 
						|
            throw new \LogicException('Faker has not been booted yet.');
 | 
						|
        }
 | 
						|
 | 
						|
        return $this->faker;
 | 
						|
    }
 | 
						|
}
 |