| Total Complexity | 6 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class ApplyMap implements Rule |
||
| 10 | { |
||
| 11 | /** @var array */ |
||
| 12 | protected $messages; |
||
| 13 | |||
| 14 | /** @var array|string */ |
||
| 15 | protected $rules; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Initialise the custom rule |
||
| 19 | * |
||
| 20 | * @param string $key |
||
| 21 | * @param array $map |
||
| 22 | */ |
||
| 23 | 9 | public function __construct(string $key, array $map) |
|
| 27 | 9 | } |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Determine if the validation rule passes |
||
| 31 | * |
||
| 32 | * @param string $attribute |
||
| 33 | * @param mixed $value |
||
| 34 | * |
||
| 35 | * @return bool |
||
| 36 | */ |
||
| 37 | 9 | public function passes($attribute, $value) |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Build the validator instance, to validate the given attribute and value |
||
| 48 | * |
||
| 49 | * @param string $attribute |
||
| 50 | * @param mixed $value |
||
| 51 | * |
||
| 52 | * @return ValidatorContract |
||
| 53 | */ |
||
| 54 | 9 | protected function makeValidator(string $attribute, $value): ValidatorContract |
|
| 55 | { |
||
| 56 | 9 | return Validator::make([$attribute => $value], [$attribute => $this->rules]); |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Get the validation error message. |
||
| 61 | * |
||
| 62 | * @return string|array |
||
| 63 | */ |
||
| 64 | 6 | public function message() |
|
| 67 | } |
||
| 68 | } |
||
| 69 |