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.
Completed
Push — master ( d57de7...55456e )
by Norbert
02:00
created

Count::getError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
4
5
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6
use Coduo\ToString\StringConverter;
7
8 View Code Duplication
final class Count implements PatternExpander
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @var null|string
12
     */
13
    private $error;
14
15
    /**
16
     * @var
17
     */
18
    private $value;
19
20
    /**
21
     * @param $value
22
     */
23
    public function __construct($value)
24
    {
25
        $this->value = $value;
26
    }
27
28
    /**
29
     * @param $value
30
     * @return boolean
31
     */
32
    public function match($value)
33
    {
34
        if (!is_array($value)) {
35
            $this->error = sprintf("Count expander require \"array\", got \"%s\".", new StringConverter($value));
36
            return false;
37
        }
38
39
        if (count($value) !== $this->value) {
40
            $this->error = sprintf("Expected count of %s is %s.", new StringConverter($value), new StringConverter($this->value));
41
            return false;
42
        }
43
44
        return true;
45
    }
46
47
    /**
48
     * @return string|null
49
     */
50
    public function getError()
51
    {
52
        return $this->error;
53
    }
54
}
55