| Total Complexity | 9 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php /** @noinspection PhpUnused */ |
||
| 18 | abstract class AbstractConstraint implements Constraint |
||
| 19 | { |
||
| 20 | |||
| 21 | /** |
||
|
1 ignored issue
–
show
|
|||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $match; |
||
| 25 | |||
| 26 | /** |
||
|
1 ignored issue
–
show
|
|||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | protected $conditionVariables; |
||
| 30 | |||
| 31 | /** |
||
|
1 ignored issue
–
show
|
|||
| 32 | * @param string $variable |
||
|
3 ignored issues
–
show
|
|||
| 33 | * @param stdClass $data; |
||
|
2 ignored issues
–
show
|
|||
| 34 | * @return bool |
||
|
1 ignored issue
–
show
|
|||
| 35 | */ |
||
| 36 | protected abstract function matchForVariable($variable, $data); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Variable constructor. |
||
| 40 | * @param string $value |
||
|
1 ignored issue
–
show
|
|||
| 41 | * @param string $match |
||
| 42 | */ |
||
| 43 | /** @noinspection PhpUnused */ |
||
|
3 ignored issues
–
show
|
|||
| 44 | 45 | public function __construct($value, $match = "any") |
|
| 48 | 45 | } |
|
| 49 | |||
| 50 | /** |
||
|
1 ignored issue
–
show
|
|||
| 51 | * @param $value |
||
|
2 ignored issues
–
show
|
|||
| 52 | * @param int|null $citationNumber |
||
|
2 ignored issues
–
show
|
|||
| 53 | * @return bool |
||
|
1 ignored issue
–
show
|
|||
| 54 | */ |
||
| 55 | 39 | public function validate($value, $citationNumber = null) |
|
| 56 | { |
||
| 57 | 39 | switch ($this->match) { |
|
| 58 | 39 | case Constraint::MATCH_ALL: |
|
| 59 | 37 | return $this->matchAll($value); |
|
| 60 | 28 | case Constraint::MATCH_NONE: |
|
| 61 | 17 | return !$this->matchAny($value); //no match for any value |
|
| 62 | 26 | case Constraint::MATCH_ANY: |
|
| 63 | default: |
||
| 64 | 26 | return $this->matchAny($value); |
|
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | 28 | private function matchAny($value) |
|
| 75 | } |
||
| 76 | |||
| 77 | 37 | private function matchAll($value) |
|
| 84 | } |
||
| 85 | } |
||
| 86 |