Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
2 / 2 |
| Civility | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
| check | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\ValidationRules\Rules; |
| 4 | |
| 5 | use Qmp\Laravel\DictionaryFormatter\Facades\DictionaryFormatter; |
| 6 | |
| 7 | class Civility extends Rule |
| 8 | { |
| 9 | /** |
| 10 | * Undocumented variable |
| 11 | * |
| 12 | * @var string |
| 13 | */ |
| 14 | protected $message = 'The :attribute must be a valid civility'; |
| 15 | |
| 16 | /** |
| 17 | * Undocumented variable |
| 18 | * |
| 19 | * @var array |
| 20 | */ |
| 21 | protected $accepted = ['0', '1']; |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * Undocumented function |
| 26 | * |
| 27 | * @param string $attribute |
| 28 | * @param mixed $value |
| 29 | * @param array $parameters |
| 30 | * @return bool |
| 31 | */ |
| 32 | public function check(string $attribute, $value, array $parameters): bool |
| 33 | { |
| 34 | $value = DictionaryFormatter::civility($value); |
| 35 | return in_array($value, $this->accepted); |
| 36 | } |
| 37 | } |