1 | <?php |
||
30 | class FieldBuilder |
||
31 | { |
||
32 | /** |
||
33 | * @var ClassMetadataBuilder |
||
34 | */ |
||
35 | private $builder; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private $mapping; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | private $version; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | private $generatedValue; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | private $sequenceDef; |
||
56 | |||
57 | /** |
||
58 | * @var string|null |
||
59 | */ |
||
60 | private $customIdGenerator; |
||
61 | |||
62 | /** |
||
63 | * @param ClassMetadataBuilder $builder |
||
64 | * @param array $mapping |
||
65 | */ |
||
66 | 5 | public function __construct(ClassMetadataBuilder $builder, array $mapping) |
|
67 | { |
||
68 | 5 | $this->builder = $builder; |
|
69 | 5 | $this->mapping = $mapping; |
|
70 | 5 | } |
|
71 | |||
72 | /** |
||
73 | * Sets length. |
||
74 | * |
||
75 | * @param int $length |
||
76 | * |
||
77 | * @return FieldBuilder |
||
78 | */ |
||
79 | 1 | public function length($length) |
|
85 | |||
86 | /** |
||
87 | * Sets nullable. |
||
88 | * |
||
89 | * @param bool $flag |
||
90 | * |
||
91 | * @return FieldBuilder |
||
92 | */ |
||
93 | 1 | public function nullable($flag = true) |
|
99 | |||
100 | /** |
||
101 | * Sets Unique. |
||
102 | * |
||
103 | * @param bool $flag |
||
104 | * |
||
105 | * @return FieldBuilder |
||
106 | */ |
||
107 | 1 | public function unique($flag = true) |
|
113 | |||
114 | /** |
||
115 | * Sets column name. |
||
116 | * |
||
117 | * @param string $name |
||
118 | * |
||
119 | * @return FieldBuilder |
||
120 | */ |
||
121 | 1 | public function columnName($name) |
|
127 | |||
128 | /** |
||
129 | * Sets Precision. |
||
130 | * |
||
131 | * @param int $p |
||
132 | * |
||
133 | * @return FieldBuilder |
||
134 | */ |
||
135 | public function precision($p) |
||
141 | |||
142 | /** |
||
143 | * Sets scale. |
||
144 | * |
||
145 | * @param int $s |
||
146 | * |
||
147 | * @return FieldBuilder |
||
148 | */ |
||
149 | public function scale($s) |
||
155 | |||
156 | /** |
||
157 | * Sets field as primary key. |
||
158 | * |
||
159 | * @deprecated Use makePrimaryKey() instead |
||
160 | * @return FieldBuilder |
||
161 | */ |
||
162 | public function isPrimaryKey() |
||
163 | { |
||
164 | return $this->makePrimaryKey(); |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Sets field as primary key. |
||
169 | * |
||
170 | * @return FieldBuilder |
||
171 | */ |
||
172 | 1 | public function makePrimaryKey() |
|
178 | |||
179 | /** |
||
180 | * Sets an option. |
||
181 | * |
||
182 | * @param string $name |
||
183 | * @param mixed $value |
||
184 | * |
||
185 | * @return FieldBuilder |
||
186 | */ |
||
187 | 1 | public function option($name, $value) |
|
193 | |||
194 | /** |
||
195 | * @param string $strategy |
||
196 | * |
||
197 | * @return FieldBuilder |
||
198 | */ |
||
199 | 2 | public function generatedValue($strategy = 'AUTO') |
|
205 | |||
206 | /** |
||
207 | * Sets field versioned. |
||
208 | * |
||
209 | * @return FieldBuilder |
||
210 | */ |
||
211 | 1 | public function isVersionField() |
|
217 | |||
218 | /** |
||
219 | * Sets Sequence Generator. |
||
220 | * |
||
221 | * @param string $sequenceName |
||
222 | * @param int $allocationSize |
||
223 | * @param int $initialValue |
||
224 | * |
||
225 | * @return FieldBuilder |
||
226 | */ |
||
227 | public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1) |
||
237 | |||
238 | /** |
||
239 | * Sets column definition. |
||
240 | * |
||
241 | * @param string $def |
||
242 | * |
||
243 | * @return FieldBuilder |
||
244 | */ |
||
245 | 1 | public function columnDefinition($def) |
|
251 | |||
252 | /** |
||
253 | * Set the FQCN of the custom ID generator. |
||
254 | * This class must extend \Doctrine\ORM\Id\AbstractIdGenerator. |
||
255 | * |
||
256 | * @param string $customIdGenerator |
||
257 | * |
||
258 | * @return $this |
||
259 | */ |
||
260 | 1 | public function setCustomIdGenerator($customIdGenerator) |
|
266 | |||
267 | /** |
||
268 | * Finalizes this field and attach it to the ClassMetadata. |
||
269 | * |
||
270 | * Without this call a FieldBuilder has no effect on the ClassMetadata. |
||
271 | * |
||
272 | * @return ClassMetadataBuilder |
||
273 | */ |
||
274 | 5 | public function build() |
|
296 | } |
||
297 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.