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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 47
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A match() 14 14 3
A getError() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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