We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 18 | abstract class AbstractComposite extends AbstractRule |
||
| 19 | { |
||
| 20 | protected $rules = []; |
||
| 21 | |||
| 22 | 16 | public function __construct(...$rule) |
|
| 23 | { |
||
| 24 | 16 | $this->addRules($rule); |
|
| 25 | 16 | } |
|
| 26 | |||
| 27 | 6 | public function setName($name) |
|
| 28 | { |
||
| 29 | 6 | $parentName = $this->getName(); |
|
| 30 | 6 | foreach ($this->rules as $rule) { |
|
| 31 | 5 | $ruleName = $rule->getName(); |
|
| 32 | 5 | if ($ruleName && $parentName !== $ruleName) { |
|
| 33 | 2 | continue; |
|
| 34 | } |
||
| 35 | |||
| 36 | 3 | $rule->setName($name); |
|
| 37 | } |
||
| 38 | |||
| 39 | 6 | return parent::setName($name); |
|
| 40 | } |
||
| 41 | |||
| 42 | 12 | public function addRule($validator, $arguments = []) |
|
| 43 | { |
||
| 44 | 12 | if (!$validator instanceof Validatable) { |
|
| 45 | $this->appendRule(Validator::buildRule($validator, $arguments)); |
||
| 46 | } else { |
||
| 47 | 12 | $this->appendRule($validator); |
|
| 48 | } |
||
| 49 | |||
| 50 | 12 | return $this; |
|
| 51 | } |
||
| 52 | |||
| 53 | 1 | public function removeRules() |
|
| 57 | |||
| 58 | 16 | public function addRules(array $validators) |
|
| 59 | { |
||
| 60 | 16 | foreach ($validators as $key => $spec) { |
|
| 61 | 1 | if ($spec instanceof Validatable) { |
|
| 62 | 1 | $this->appendRule($spec); |
|
| 63 | } elseif (is_numeric($key) && is_array($spec)) { |
||
| 64 | $this->addRules($spec); |
||
| 65 | } elseif (is_array($spec)) { |
||
| 66 | $this->addRule($key, $spec); |
||
| 67 | } else { |
||
| 68 | 1 | $this->addRule($spec); |
|
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | 16 | return $this; |
|
| 73 | } |
||
| 74 | |||
| 75 | 3 | public function getRules() |
|
| 79 | |||
| 80 | 4 | public function hasRule($validator) |
|
| 81 | { |
||
| 82 | 4 | if (empty($this->rules)) { |
|
| 83 | 1 | return false; |
|
| 100 | |||
| 101 | 13 | protected function appendRule(Validatable $validator) |
|
| 109 | |||
| 110 | protected function validateRules($input) |
||
| 124 | } |
||
| 125 |