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.

Comparer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
c 1
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Isolate\UnitOfWork\Entity;
4
5
use Isolate\UnitOfWork\Entity\Definition\Repository;
6
use Isolate\UnitOfWork\Entity\Property\PHPUnitValueComparer;
7
use Isolate\UnitOfWork\Exception\InvalidArgumentException;
8
9
/**
10
 * @api
11
 */
12
class Comparer
13
{
14
    /**
15
     * @var PHPUnitValueComparer
16
     */
17
    private $propertyValueComparer;
18
19
    /**
20
     * @var Repository
21
     */
22
    private $definitions;
23
24
    /**
25
     * @param Repository $definitions
26
     */
27
    public function __construct(Repository $definitions)
28
    {
29
        $this->propertyValueComparer = new PHPUnitValueComparer();
30
        $this->definitions = $definitions;
31
    }
32
33
    /**
34
     * @param $firstEntity
35
     * @param $secondEntity
36
     * @return bool
37
     * @throws InvalidArgumentException
38
     * 
39
     * @api
40
     */
41
    public function areEqual($firstEntity, $secondEntity)
42
    {
43
        $entityDefinition = $this->definitions->getDefinition($firstEntity);
44
45
        if (!$entityDefinition->fitsFor($secondEntity)) {
46
            throw new InvalidArgumentException("You can't compare entities of different type.");
47
        }
48
49
        foreach ($entityDefinition->getObservedProperties() as $property) {
50
            if ($this->propertyValueComparer->hasDifferentValue($property, $firstEntity, $secondEntity)) {
51
                return false;
52
            }
53
        }
54
55
        return true;
56
    }
57
}
58