We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 18 | class KeyValue extends AbstractRule |
||
| 19 | { |
||
| 20 | public $comparedKey; |
||
| 21 | public $ruleName; |
||
| 22 | public $baseKey; |
||
| 23 | |||
| 24 | public function __construct($comparedKey, $ruleName, $baseKey) |
||
| 25 | { |
||
| 26 | $this->comparedKey = $comparedKey; |
||
| 27 | $this->ruleName = $ruleName; |
||
| 28 | $this->baseKey = $baseKey; |
||
| 29 | } |
||
| 30 | |||
| 31 | private function getRule($input) |
||
| 32 | { |
||
| 33 | if (!isset($input[$this->comparedKey])) { |
||
| 34 | throw $this->reportError($this->comparedKey); |
||
| 35 | } |
||
| 36 | |||
| 37 | if (!isset($input[$this->baseKey])) { |
||
| 38 | throw $this->reportError($this->baseKey); |
||
| 39 | } |
||
| 40 | |||
| 41 | try { |
||
| 42 | $rule = Validator::__callStatic($this->ruleName, [$input[$this->baseKey]]); |
||
| 43 | $rule->setName($this->comparedKey); |
||
|
|
|||
| 44 | } catch (ComponentException $exception) { |
||
| 45 | throw $this->reportError($input, ['component' => true]); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $rule; |
||
| 49 | } |
||
| 50 | |||
| 51 | private function overwriteExceptionParams(ValidationException $exception) |
||
| 66 | |||
| 67 | public function assert($input) |
||
| 68 | { |
||
| 79 | |||
| 80 | public function check($input) |
||
| 92 | |||
| 93 | public function validate($input) |
||
| 103 | } |
||
| 104 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: