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 — master (#644)
by Augusto
04:27
created

Factory   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 96%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 47
ccs 24
cts 25
cp 0.96
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRulePrefixes() 0 4 1
A appendRulePrefix() 0 9 1
A prependRulePrefix() 0 4 1
B rule() 0 22 5
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation;
13
14
use ReflectionClass;
15
use Respect\Validation\Exceptions\ComponentException;
16
17
class Factory
18
{
19
    protected $rulePrefixes = ['Respect\\Validation\\Rules\\'];
20
21 10
    public function getRulePrefixes()
22
    {
23 10
        return $this->rulePrefixes;
24
    }
25
26 3
    public function appendRulePrefix($rulePrefix)
27
    {
28 3
        $namespaceSeparator = '\\';
29 3
        $rulePrefix = rtrim($rulePrefix, $namespaceSeparator);
30 3
        array_push(
31 3
            $this->rulePrefixes,
32
            $rulePrefix . $namespaceSeparator
33 3
        );
34 3
    }
35
36 1
    public function prependRulePrefix($rulePrefix)
37
    {
38 1
        array_unshift($this->rulePrefixes, $rulePrefix);
39 1
    }
40
41 6
    public function rule($ruleName, array $arguments = [])
42
    {
43 6
        if ($ruleName instanceof Validatable) {
44
            return $ruleName;
45
        }
46
47 6
        foreach ($this->getRulePrefixes() as $prefix) {
48 6
            $className = $prefix.ucfirst($ruleName);
49 6
            if (!class_exists($className)) {
50 3
                continue;
51
            }
52
53 4
            $reflection = new ReflectionClass($className);
54 4
            if (!$reflection->isSubclassOf('Respect\\Validation\\Validatable')) {
55 1
                throw new ComponentException(sprintf('"%s" is not a valid respect rule', $className));
56
            }
57
58 3
            return $reflection->newInstanceArgs($arguments);
59 2
        }
60
61 2
        throw new ComponentException(sprintf('"%s" is not a valid rule name', $ruleName));
62
    }
63
}
64