We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
19 | abstract class AbstractComposite extends AbstractRule |
||
20 | { |
||
21 | protected $rules = []; |
||
22 | |||
23 | 16 | public function __construct() |
|
27 | |||
28 | 6 | public function setName($name) |
|
29 | { |
||
30 | 6 | $parentName = $this->getName(); |
|
31 | 6 | foreach ($this->rules as $rule) { |
|
32 | 5 | $ruleName = $rule->getName(); |
|
33 | 5 | if ($ruleName && $parentName !== $ruleName) { |
|
34 | 2 | continue; |
|
35 | } |
||
36 | |||
37 | 3 | $rule->setName($name); |
|
38 | } |
||
39 | |||
40 | 6 | return parent::setName($name); |
|
41 | } |
||
42 | |||
43 | 12 | public function addRule($validator, $arguments = []) |
|
44 | { |
||
45 | 12 | if (!$validator instanceof Validatable) { |
|
46 | $this->appendRule(Validator::buildRule($validator, $arguments)); |
||
47 | } else { |
||
48 | 12 | $this->appendRule($validator); |
|
49 | } |
||
50 | |||
51 | 12 | return $this; |
|
52 | } |
||
53 | |||
54 | 1 | public function removeRules() |
|
58 | |||
59 | 16 | public function addRules(array $validators) |
|
60 | { |
||
61 | 16 | foreach ($validators as $key => $spec) { |
|
62 | 1 | if ($spec instanceof Validatable) { |
|
63 | 1 | $this->appendRule($spec); |
|
64 | } elseif (is_numeric($key) && is_array($spec)) { |
||
65 | $this->addRules($spec); |
||
66 | } elseif (is_array($spec)) { |
||
67 | $this->addRule($key, $spec); |
||
68 | } else { |
||
69 | $this->addRule($spec); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | 16 | return $this; |
|
74 | } |
||
75 | |||
76 | 3 | public function getRules() |
|
80 | |||
81 | 4 | public function hasRule($validator) |
|
82 | { |
||
83 | 4 | if (empty($this->rules)) { |
|
84 | 1 | return false; |
|
85 | } |
||
86 | |||
87 | 3 | if ($validator instanceof Validatable) { |
|
88 | 2 | return isset($this->rules[spl_object_hash($validator)]); |
|
89 | } |
||
90 | |||
91 | 1 | if (is_string($validator)) { |
|
92 | 1 | foreach ($this->rules as $rule) { |
|
93 | 1 | if (get_class($rule) == __NAMESPACE__.'\\'.$validator) { |
|
94 | return true; |
||
95 | } |
||
96 | } |
||
97 | } |
||
98 | |||
99 | 1 | return false; |
|
100 | } |
||
101 | |||
102 | 13 | protected function appendRule(Validatable $validator) |
|
110 | |||
111 | protected function validateRules($input) |
||
125 | |||
126 | private function setExceptionTemplate(ValidationException $exception) |
||
142 | } |
||
143 |