GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SimpleFactory   C
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 21

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 21
dl 0
loc 82
rs 6.1111

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createMatcher() 0 4 1
A buildMatchers() 0 15 1
A buildOrMatcher() 0 19 1
A buildScalarMatchers() 0 18 1
A buildParser() 0 4 1
1
<?php
2
3
namespace Coduo\PHPMatcher\Factory;
4
5
use Coduo\PHPMatcher\Factory;
6
use Coduo\PHPMatcher\Lexer;
7
use Coduo\PHPMatcher\Matcher;
8
use Coduo\PHPMatcher\Parser;
9
10
class SimpleFactory implements Factory
11
{
12
    /**
13
     * @return Matcher
14
     */
15
    public function createMatcher()
16
    {
17
        return new Matcher($this->buildMatchers());
18
    }
19
20
    /**
21
     * @return Matcher\ChainMatcher
22
     */
23
    protected function buildMatchers()
24
    {
25
        $scalarMatchers = $this->buildScalarMatchers();
26
        $orMatcher = $this->buildOrMatcher();
27
28
        $chainMatcher = new Matcher\ChainMatcher(array(
29
            $scalarMatchers,
30
            $orMatcher,
31
            new Matcher\JsonMatcher($orMatcher),
32
            new Matcher\XmlMatcher($orMatcher),
33
            new Matcher\TextMatcher($scalarMatchers, $this->buildParser())
34
        ));
35
36
        return $chainMatcher;
37
    }
38
39
    /**
40
     * @return Matcher\ChainMatcher
41
     */
42
    protected function buildOrMatcher()
43
    {
44
        $scalarMatchers = $this->buildScalarMatchers();
45
        $orMatcher = new Matcher\OrMatcher($scalarMatchers);
46
        $arrayMatcher = new Matcher\ArrayMatcher(
47
            new Matcher\ChainMatcher(array(
48
                $orMatcher,
49
                $scalarMatchers
50
            )),
51
            $this->buildParser()
52
        );
53
54
        $chainMatcher = new Matcher\ChainMatcher(array(
55
            $orMatcher,
56
            $arrayMatcher,
57
        ));
58
59
        return $chainMatcher;
60
    }
61
62
    /**
63
     * @return Matcher\ChainMatcher
64
     */
65
    protected function buildScalarMatchers()
66
    {
67
        $parser = $this->buildParser();
68
69
        return new Matcher\ChainMatcher(array(
70
            new Matcher\CallbackMatcher(),
71
            new Matcher\ExpressionMatcher(),
72
            new Matcher\NullMatcher(),
73
            new Matcher\StringMatcher($parser),
74
            new Matcher\IntegerMatcher($parser),
75
            new Matcher\BooleanMatcher(),
76
            new Matcher\DoubleMatcher($parser),
77
            new Matcher\NumberMatcher(),
78
            new Matcher\ScalarMatcher(),
79
            new Matcher\WildcardMatcher(),
80
            new Matcher\UuidMatcher(),
81
        ));
82
    }
83
84
    /**
85
     * @return Parser
86
     */
87
    protected function buildParser()
88
    {
89
        return new Parser(new Lexer(), new Parser\ExpanderInitializer());
90
    }
91
}
92