FEATURE: Add basic support for faker
This commit is contained in:
parent
ee310bd580
commit
3b0e0bdd0f
3 changed files with 23 additions and 0 deletions
|
@ -17,3 +17,6 @@ data:
|
||||||
type: userfunc
|
type: userfunc
|
||||||
class: DSiepmann\Userfunction\RepeatingFilenames
|
class: DSiepmann\Userfunction\RepeatingFilenames
|
||||||
method: filename
|
method: filename
|
||||||
|
date:
|
||||||
|
type: faker
|
||||||
|
formatter: dateTime
|
||||||
|
|
|
@ -71,6 +71,14 @@ types are supported:
|
||||||
class: DSiepmann\Userfunction\RepeatingFilenames
|
class: DSiepmann\Userfunction\RepeatingFilenames
|
||||||
method: filename
|
method: filename
|
||||||
|
|
||||||
|
``faker``
|
||||||
|
Uses a formatter defined by `faker`_.
|
||||||
|
|
||||||
|
.. code:: yml
|
||||||
|
|
||||||
|
date:
|
||||||
|
type: faker
|
||||||
|
formatter: dateTime
|
||||||
|
|
||||||
.. _faker: https://github.com/fzaninotto/Faker
|
.. _faker: https://github.com/fzaninotto/Faker
|
||||||
.. _Doctrine DBAL: http://www.doctrine-project.org/projects/dbal.html
|
.. _Doctrine DBAL: http://www.doctrine-project.org/projects/dbal.html
|
||||||
|
|
|
@ -121,6 +121,18 @@ class FakeMysqlCommand extends Command
|
||||||
return $userfunction->$userMethod();
|
return $userfunction->$userMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config['type'] === 'faker') {
|
||||||
|
$formatterToUse = $config['formatter'];
|
||||||
|
|
||||||
|
$fakerData = $this->faker->$formatterToUse();
|
||||||
|
|
||||||
|
if ($fakerData instanceof \DateTime) {
|
||||||
|
$fakerData = $fakerData->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fakerData;
|
||||||
|
}
|
||||||
|
|
||||||
throw new \Exception('Unkown configured value.', 1486135949);
|
throw new \Exception('Unkown configured value.', 1486135949);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue