| Total Complexity | 10 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 5 | Trait ExtraCheck{ |
||
| 6 | protected static array $data = []; |
||
| 7 | protected static array $validators = []; |
||
| 8 | protected static string $model = ''; |
||
| 9 | protected static array $required = []; |
||
| 10 | protected static array $errors = []; |
||
| 11 | |||
| 12 | protected static function check_requireds() |
||
| 13 | { |
||
| 14 | if(count(self::$required) > 0){ |
||
| 15 | self::$errors[] = [ |
||
| 16 | 'As seguintes informações não poderam ser validadas: '.implode(', ',array_keys(self::$required)).'.' |
||
| 17 | ]; |
||
| 18 | } |
||
| 19 | } |
||
| 20 | |||
| 21 | public static function validateDate($date, $format = 'Y-m-d H:i:s') |
||
| 22 | { |
||
| 23 | $d = \DateTime::createFromFormat($format, $date); |
||
| 24 | return $d && $d->format($format) == $date; |
||
| 25 | } |
||
| 26 | |||
| 27 | protected static function check_required(string $param): bool |
||
| 28 | { |
||
| 29 | return (array_key_exists('required',self::$validators[self::$model]->getRules(self::$data['role'])[$param]) && self::$validators[self::$model]->getRules(self::$data['role'])[$param]['required']); |
||
| 30 | } |
||
| 31 | |||
| 32 | protected static function toNext(string $param, $value) |
||
| 35 | } |
||
| 36 | |||
| 37 | protected static function testArray(string $param, $value): ?array |
||
| 45 | } |
||
| 46 | } |
||
| 47 |