Fakerino\Fakerino::create PHP Method

create() public static method

Bootstrap function for Fakerino, setups the global configuration.
public static create ( null | array | string $conf = null ) : FakeDataFactory
$conf null | array | string
return Fakerino\Core\FakeDataFactory
    public static function create($conf = null)
    {
        self::$defaultConf = new FakerinoConf();
        self::$defaultConf->loadConfiguration();
        if ($conf !== null) {
            $confArray = $conf;
            if (!is_array($conf)) {
                $confTypeFactory = new FileConfigurationLoaderFactory($conf);
                $confParser = $confTypeFactory->load();
                $confArray = $confParser->toArray();
            }
            $conf = $confArray;
        }
        self::$defaultConf = new FakerinoConf($conf);
        self::$defaultConf->loadConfiguration();
        return new FakeDataFactory(self::getDefaultHandler(), new DoctrineLayer(self::getDatabaseConfig()), new TwigTemplate());
    }

Usage Example

示例#1
0
 /**
  * Runs the command.
  *
  * @return mixed
  */
 public function run()
 {
     if ($this->help) {
         return $this->showHelp();
     }
     if ($this->confFile) {
         $fakerino = Fakerino::create($this->confFile);
     } else {
         $fakerino = Fakerino::create();
         if ($this->locale) {
             $conf = array();
             $conf['locale'] = $this->locale;
             $fakerino = Fakerino::create($conf);
         }
     }
     if (!$this->num) {
         $this->num = 1;
     }
     if ($this->table) {
         $fakerino->num($this->num)->fakeTable($this->table);
         return;
     }
     if ($this->templateSource) {
         return $fakerino->num($this->num)->fakeTemplate($this->templateSource) . PHP_EOL;
     }
     $fakerino = $fakerino->fake($this->input)->num($this->num);
     if ($this->json) {
         $result = $fakerino->toJson();
     } else {
         $result = (string) $fakerino;
     }
     return $result . PHP_EOL;
 }
All Usage Examples Of Fakerino\Fakerino::create