| Total Complexity | 7 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | final class HasNotKey |
||
| 12 | { |
||
| 13 | public const PRESENT_KEY = 'has-not-key.present-key'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $key; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var callable $key -> $data -> string[] |
||
| 22 | */ |
||
| 23 | private $errorFormatter; |
||
| 24 | |||
| 25 | private function __construct(string $key, ?callable $errorFormatter = null) |
||
| 26 | { |
||
| 27 | $this->key = $key; |
||
| 28 | $this->errorFormatter = is_callable($errorFormatter) ? |
||
| 29 | $errorFormatter : |
||
| 30 | function (string $key, $data) { |
||
| 31 | return [self::PRESENT_KEY]; |
||
| 32 | }; |
||
| 33 | } |
||
| 34 | |||
| 35 | public static function withKey(string $key): self |
||
| 38 | } |
||
| 39 | |||
| 40 | public static function withKeyAndFormatter(string $key, callable $errorFormatter): self |
||
| 41 | { |
||
| 42 | return new self($key, $errorFormatter); |
||
| 43 | } |
||
| 44 | |||
| 45 | public static function withKeyAndTranslator(string $key, Translator $translator): self |
||
| 51 | } |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function validate($data, array $context = []): ValidationResult |
||
| 64 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.