| Total Complexity | 7 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | Class Rules |
||
| 6 | { |
||
| 7 | use Helper; |
||
| 8 | |||
| 9 | private string $action; |
||
| 10 | |||
| 11 | private array $form = array(); |
||
| 12 | |||
| 13 | public function __construct(object $model) |
||
| 14 | { |
||
| 15 | $this->form['model'] = ucfirst(get_class($model)); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function action(string $action): Rules |
||
| 19 | { |
||
| 20 | $this->action = $action; |
||
| 21 | return $this; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function field(string $field, array $test, ?string $placeholder = null): Rules |
||
| 25 | { |
||
| 26 | if(empty($this->action)){ |
||
| 27 | self::$errors[] = self::$err['nFoundForm']; |
||
| 28 | return $this; |
||
| 29 | } |
||
| 30 | |||
| 31 | $this->form[$this->action][$field] = $test; |
||
| 32 | $this->form[$this->action][$field]['placeholder'] = (null !== $placeholder) ? $placeholder : $test; |
||
| 33 | return $this; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getRules(string $action): Array |
||
| 39 | } |
||
| 40 | } |
||
| 41 |