1 | <?php |
||
9 | class ModelFactoryBuilder |
||
10 | { |
||
11 | /** |
||
12 | * Name of class. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $class; |
||
17 | |||
18 | /** |
||
19 | * Definition name. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name; |
||
24 | |||
25 | /** |
||
26 | * Array of all definitions. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $definitions; |
||
31 | |||
32 | /** |
||
33 | * Faker instance. |
||
34 | * |
||
35 | * @var Generator |
||
36 | */ |
||
37 | protected $faker; |
||
38 | |||
39 | /** |
||
40 | * Number of times to run factory. |
||
41 | * |
||
42 | * @var int|null |
||
43 | */ |
||
44 | protected $times; |
||
45 | |||
46 | /** |
||
47 | * Construct. |
||
48 | * |
||
49 | * @param string $class |
||
50 | * @param string $name |
||
51 | * @param array $definitions |
||
52 | * @param Generator $faker |
||
53 | */ |
||
54 | public function __construct($class, $name, array $definitions, Generator $faker) |
||
61 | |||
62 | /** |
||
63 | * Make an instance of class. |
||
64 | * |
||
65 | * @param array $attributes |
||
66 | * |
||
67 | * @return Phalcon\Mvc\Model|array |
||
68 | */ |
||
69 | public function make(array $attributes = []) |
||
83 | |||
84 | /** |
||
85 | * Create an instance of class and persist in database. |
||
86 | * |
||
87 | * @param array $attributes |
||
88 | * |
||
89 | * @return Phalcon\Mvc\Model|array |
||
90 | */ |
||
91 | public function create(array $attributes = []) |
||
109 | |||
110 | /** |
||
111 | * Set the number of times to run the make/create the class. |
||
112 | * |
||
113 | * @param int|null $times |
||
114 | * |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function times($times = null) |
||
123 | |||
124 | /** |
||
125 | * Make an instance of the class with the given attributes. |
||
126 | * |
||
127 | * @param array $attributes |
||
128 | * |
||
129 | * @throws FactoryNotFound |
||
130 | * |
||
131 | * @return Phalcon\Mvc\Model |
||
132 | */ |
||
133 | protected function makeInstance(array $attributes = []) |
||
150 | |||
151 | /** |
||
152 | * Call any closures in attributes. |
||
153 | * |
||
154 | * @param array $attributes |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | protected function callClosureAttributes(array $attributes) |
||
168 | } |
||
169 |