forked from kevindierkx/laravel-domain-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidatorWrapper.php
38 lines (32 loc) · 975 Bytes
/
ValidatorWrapper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace Bakame\Laravel\Pdp;
use Illuminate\Contracts\Validation\Validator;
class ValidatorWrapper
{
/**
* @var callable
*/
private $callable;
/**
* New instance.
*
* @param callable $callable a callable that takes one argument
* and returns true if the argument is valid
* or false otherwise
*/
public function __construct(callable $callable)
{
$this->callable = $callable;
}
/**
* @param string $attribute
* @param mixed $value
* @param array $params
* @param \Illuminate\Contracts\Validation\Validator $validator
*/
public function __invoke(string $attribute, $value, array $params, Validator $validator): bool
{
return ($this->callable)($value);
}
}