Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — 0.9 (#694)
by
unknown
03:32
created

Factory   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 95.45%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 42
ccs 21
cts 22
cp 0.9545
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRulePrefixes() 0 4 1
A appendRulePrefix() 0 4 1
A prependRulePrefix() 0 4 1
B rule() 0 22 5
1
<?php
2
3
namespace Respect\Validation;
4
5
use ReflectionClass;
6
use Respect\Validation\Exceptions\ComponentException;
7
8
class Factory
9
{
10
    protected $rulePrefixes = array('Respect\\Validation\\Rules\\');
11
12 35
    public function getRulePrefixes()
13
    {
14 35
        return $this->rulePrefixes;
15
    }
16
17 2
    public function appendRulePrefix($rulePrefix)
18 1
    {
19 2
        array_push($this->rulePrefixes, $rulePrefix);
20 2
    }
21
22 1
    public function prependRulePrefix($rulePrefix)
23
    {
24 1
        array_unshift($this->rulePrefixes, $rulePrefix);
25 1
    }
26
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