1 | <?php |
||
10 | class ModelFactory extends Component |
||
11 | { |
||
12 | use Filesystem; |
||
13 | |||
14 | /** |
||
15 | * Faker instance. |
||
16 | * |
||
17 | * @var Generator |
||
18 | */ |
||
19 | protected $faker; |
||
20 | |||
21 | /** |
||
22 | * Array of user defined factory definitions. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $definitions; |
||
27 | |||
28 | /** |
||
29 | * Construct. |
||
30 | * |
||
31 | * @param Generator $faker |
||
32 | */ |
||
33 | public function __construct(Generator $faker) |
||
39 | |||
40 | /** |
||
41 | * Make instances of class, overriding default values with attributes. |
||
42 | * |
||
43 | * @param string $class |
||
44 | * @param array $attributes |
||
45 | * @param int $times |
||
46 | * |
||
47 | * @return Phalcon\Mvc\Model|array |
||
48 | */ |
||
49 | public function make($class, array $attributes = [], $times = null) |
||
53 | |||
54 | /** |
||
55 | * Make instances of class using name. |
||
56 | * |
||
57 | * @param string $class |
||
58 | * @param string $name |
||
59 | * @param array $attributes |
||
60 | * @param int $times |
||
61 | * |
||
62 | * @return Phalcon\Mvc\Model|array |
||
63 | */ |
||
64 | public function makeAs($class, $name, array $attributes = [], $times = null) |
||
68 | |||
69 | /** |
||
70 | * Create instances of class, overriding default values with attributes. |
||
71 | * |
||
72 | * @param string $class |
||
73 | * @param array $attributes |
||
74 | * @param int $times |
||
75 | * |
||
76 | * @return Phalcon\Mvc\Model|array |
||
77 | */ |
||
78 | public function create($class, array $attributes = [], $times = null) |
||
82 | /** |
||
83 | * Create instances of class using name. |
||
84 | * |
||
85 | * @param string $class |
||
86 | * @param string $name |
||
87 | * @param array $attributes |
||
88 | * @param int $times |
||
89 | * |
||
90 | * @return Phalcon\Mvc\Model|array |
||
91 | */ |
||
92 | public function createAs($class, $name, array $attributes = [], $times = null) |
||
96 | |||
97 | /** |
||
98 | * Get instance of factory builder with set attributes. |
||
99 | * |
||
100 | * @param string $class |
||
101 | * @param string $name |
||
102 | * |
||
103 | * @return ModelFactoryBuilder |
||
104 | */ |
||
105 | public function forClass($class, $name = 'default') |
||
114 | |||
115 | /** |
||
116 | * Load factory definitions onto object. |
||
117 | * |
||
118 | * @return this |
||
119 | */ |
||
120 | protected function load() |
||
147 | |||
148 | /** |
||
149 | * Define a class with a given set of attributes. |
||
150 | * |
||
151 | * @param string $class |
||
152 | * @param callable $attributes |
||
153 | * @param string $name |
||
154 | * |
||
155 | * @return this |
||
156 | */ |
||
157 | public function define($class, callable $attributes, $name = 'default') |
||
163 | } |
||
164 |