| Total Complexity | 3 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | trait HandlesValidationErrors |
||
| 9 | { |
||
| 10 | public $showErrors = true; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Returns a boolean wether the given attribute has an error |
||
| 14 | * and the should be shown. |
||
| 15 | * |
||
| 16 | * @param string $name |
||
| 17 | * @param string $bag |
||
| 18 | * @return boolean |
||
| 19 | */ |
||
| 20 | public function hasErrorAndShow(string $name, string $bag = 'default'): bool |
||
| 21 | { |
||
| 22 | return $this->showErrors |
||
| 23 | ? $this->hasError($name, $bag) |
||
| 24 | : false; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Returns a boolean wether the given attribute has an error. |
||
| 29 | * |
||
| 30 | * @param string $name |
||
| 31 | * @param string $bag |
||
| 32 | * @return boolean |
||
| 33 | */ |
||
| 34 | public function hasError(string $name, string $bag = 'default'): bool |
||
| 41 | } |
||
| 42 | } |
||
| 43 |