Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithFaker.php
Строк: 43
<?php

namespace IlluminateFoundationTesting;

use 
FakerFactory;
use 
FakerGenerator;

trait 
WithFaker
{
    
/**
     * The Faker instance.
     *
     * @var FakerGenerator
     */
    
protected $faker;

    
/**
     * Setup up the Faker instance.
     *
     * @return void
     */
    
protected function setUpFaker()
    {
        
$this->faker $this->makeFaker();
    }

    
/**
     * Get the default Faker instance for a given locale.
     *
     * @param  string|null  $locale
     * @return FakerGenerator
     */
    
protected function faker($locale null)
    {
        return 
is_null($locale) ? $this->faker $this->makeFaker($locale);
    }

    
/**
     * Create a Faker instance for the given locale.
     *
     * @param  string|null  $locale
     * @return FakerGenerator
     */
    
protected function makeFaker($locale null)
    {
        if (isset(
$this->app)) {
            
$locale ??= $this->app->make('config')->get('app.faker_locale'Factory::DEFAULT_LOCALE);

            if (
$this->app->bound(Generator::class)) {
                return 
$this->app->make(Generator::class, ['locale' => $locale]);
            }
        }

        return 
Factory::create($locale ?? Factory::DEFAULT_LOCALE);
    }
}
Онлайн: 0
Реклама