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.

Contains   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 58
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A match() 0 18 4
A getError() 0 4 1
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
final class Contains implements PatternExpander
9
{
10
    /**
11
     * @var null|string
12
     */
13
    private $error;
14
15
    /**
16
     * @var
17
     */
18
    private $string;
19
20
    /**
21
     * @var bool
22
     */
23
    private $ignoreCase;
24
25
    /**
26
     * @param $string
27
     * @param bool $ignoreCase
28
     */
29
    public function __construct($string, $ignoreCase = false)
30
    {
31
        $this->string = $string;
32
        $this->ignoreCase = $ignoreCase;
33
    }
34
35
    /**
36
     * @param $value
37
     * @return boolean
38
     */
39
    public function match($value)
40
    {
41
        if (!is_string($value)) {
42
            $this->error = sprintf("Contains expander require \"string\", got \"%s\".", new StringConverter($value));
43
            return false;
44
        }
45
46
        $contains = $this->ignoreCase
47
            ? mb_strpos(mb_strtolower($value), mb_strtolower($this->string))
48
            : mb_strpos($value, $this->string);
49
50
        if ($contains === false) {
51
            $this->error = sprintf("String \"%s\" doesn't contains \"%s\".", $value, $this->string);
52
            return false;
53
        }
54
55
        return true;
56
    }
57
58
    /**
59
     * @return string|null
60
     */
61
    public function getError()
62
    {
63
        return $this->error;
64
    }
65
}
66