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.

DiffCompare::compare()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-07-30
7
 *
8
 */
9
namespace Chapi\Component\Comparison;
10
11
use Chapi\Vendor\Diff;
12
13
class DiffCompare implements DiffCompareInterface
14
{
15
    /**
16
     * @var Diff
17
     */
18
    private static $compare;
19
20
    /**
21
     * @param mixed $valueA
22
     * @param mixed $valueB
23
     * @return string
24
     */
25
    public function compare($valueA, $valueB)
26
    {
27
        $compare = self::getCompare();
28
29
        $diff = $compare::compare(
30
            $this->valueToString($valueA),
31
            $this->valueToString($valueB)
32
        );
33
34
        return trim($compare::toString($diff));
35
    }
36
37
    /**
38
     * @param mixed $value
39
     * @return string
40
     */
41
    private function valueToString($value)
42
    {
43
        if (is_array($value) || is_object($value)) {
44
            return trim(json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
45
        }
46
47
        return trim((string) $value);
48
    }
49
50
    /**
51
     * @return Diff
52
     */
53
    private static function getCompare()
54
    {
55
        if (is_null(self::$compare)) {
56
            self::$compare = new Diff();
57
        }
58
59
        return self::$compare;
60
    }
61
}
62