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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 49
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A compare() 0 11 1
A valueToString() 0 8 3
A getCompare() 0 8 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