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

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A areEqual() 0 16 4
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