We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5.0113 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 32 | public function rule($ruleName, array $arguments = array()) |
|
| 28 | { |
||
| 29 | 32 | if ($ruleName instanceof Validatable) { |
|
| 30 | return $ruleName; |
||
| 31 | } |
||
| 32 | |||
| 33 | 32 | foreach ($this->getRulePrefixes() as $prefix) { |
|
| 34 | 32 | $className = $prefix.ucfirst($ruleName); |
|
| 35 | 32 | if (! class_exists($className)) { |
|
| 36 | 3 | continue; |
|
| 37 | } |
||
| 38 | |||
| 39 | 30 | $reflection = new ReflectionClass($className); |
|
| 40 | 30 | if (! $reflection->isSubclassOf('Respect\\Validation\\Validatable')) { |
|
| 41 | 1 | throw new ComponentException(sprintf('"%s" is not a valid respect rule', $className)); |
|
| 42 | } |
||
| 43 | |||
| 44 | 29 | return $reflection->newInstanceArgs($arguments); |
|
| 45 | 2 | } |
|
| 46 | |||
| 47 | 2 | throw new ComponentException(sprintf('"%s" is not a valid rule name', $ruleName)); |
|
| 48 | } |
||
| 49 | } |
||
| 50 |