1 | <?php |
||
7 | class RuleParser |
||
8 | { |
||
9 | /** |
||
10 | * @param $rule |
||
11 | * @return string|null |
||
12 | */ |
||
13 | public static function parseRule($rule = null) |
||
41 | |||
42 | /** |
||
43 | * @param string $rawRules |
||
44 | * @return string |
||
45 | */ |
||
46 | public static function toRule(string $rawRules): string |
||
79 | /** |
||
80 | * Parse the rules to column creation methods |
||
81 | * |
||
82 | * @param $fields |
||
83 | * @return string |
||
84 | */ |
||
85 | public static function fieldsToMigrationMethods(array $fields): string |
||
110 | |||
111 | /** |
||
112 | * @param $rule |
||
113 | * @return string |
||
114 | */ |
||
115 | public static function getAdditionalUpMethods($rule): string |
||
125 | |||
126 | /** |
||
127 | * Check if $rule should be handled as single method |
||
128 | * |
||
129 | * @param $rule |
||
130 | * @return mixed|string |
||
131 | */ |
||
132 | public static function isMethodOnly($rule) |
||
141 | |||
142 | /** |
||
143 | * Check if $rule contains any of the possible methods |
||
144 | * |
||
145 | * @param $rule |
||
146 | * @return mixed|string |
||
147 | */ |
||
148 | public static function getMethod($rule) |
||
158 | |||
159 | /** |
||
160 | * Parses the max:* rule |
||
161 | * |
||
162 | * @param $rule |
||
163 | * @return string |
||
164 | */ |
||
165 | public static function getMax($rule): string |
||
175 | |||
176 | /** |
||
177 | * Gets old name for renaming column |
||
178 | * |
||
179 | * @param $rule |
||
180 | * @return string |
||
181 | */ |
||
182 | public static function getRenameFrom($rule): string |
||
196 | |||
197 | /** |
||
198 | * Checks if column can be set to nullable |
||
199 | * |
||
200 | * @param $rule |
||
201 | * @return boolean |
||
202 | */ |
||
203 | public static function isRequired($rule): bool |
||
209 | |||
210 | /** |
||
211 | * Checks if columns needs to be set to unique |
||
212 | * |
||
213 | * @param $rule |
||
214 | * @return boolean |
||
215 | */ |
||
216 | public static function isIncrements($rule): bool |
||
226 | |||
227 | /** |
||
228 | * Checks if columns needs to be set to unique |
||
229 | * |
||
230 | * @param $rule |
||
231 | * @return boolean |
||
232 | */ |
||
233 | public static function isUnique($rule): bool |
||
237 | |||
238 | /** |
||
239 | * Checks if columns is unsigned |
||
240 | * |
||
241 | * @param $rule |
||
242 | * @return boolean |
||
243 | */ |
||
244 | public static function isUnsigned($rule): bool |
||
249 | |||
250 | |||
251 | /** |
||
252 | * Checks if columns has changed |
||
253 | * |
||
254 | * @param $rule |
||
255 | * @return boolean |
||
256 | */ |
||
257 | public static function hasChanged($rule): bool |
||
261 | |||
262 | /** |
||
263 | * Checks if columns needs to be constructed as a foreign key |
||
264 | * |
||
265 | * @param $rule |
||
266 | * @return boolean |
||
267 | */ |
||
268 | public static function isForeign($rule): bool |
||
272 | |||
273 | /** |
||
274 | * For aesthetic reasons |
||
275 | * |
||
276 | * @param $rule |
||
277 | * @param $needles |
||
278 | * @return bool |
||
279 | */ |
||
280 | private static function ruleContains($rule, array $needles): bool |
||
288 | } |
||
289 | |||
290 |