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.

EntityIdentifier   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isEntity() 0 4 1
A isPersisted() 0 8 1
A getIdentity() 0 7 1
A validateEntity() 0 6 2
1
<?php
2
3
namespace Isolate\UnitOfWork\Entity\Identifier;
4
5
use Isolate\UnitOfWork\Entity\Definition\Repository;
6
use Isolate\UnitOfWork\Entity\Identifier;
7
use Isolate\UnitOfWork\Exception\RuntimeException;
8
use Isolate\UnitOfWork\Object\PropertyAccessor;
9
10
class EntityIdentifier implements Identifier
11
{
12
    /**
13
     * @var Repository
14
     */
15
    private $definitions;
16
17
    /**
18
     * @var PropertyAccessor
19
     */
20
    private $propertyAccessor;
21
22
    /**
23
     * @param Repository $definitions
24
     */
25
    public function __construct(Repository $definitions)
26
    {
27
        $this->definitions = $definitions;
28
        $this->propertyAccessor = new PropertyAccessor();
29
    }
30
31
    /**
32
     * @param $object
33
     * @return boolean
34
     */
35
    public function isEntity($object)
36
    {
37
        return $this->definitions->hasDefinition($object);
38
    }
39
40
    /**
41
     * @param mixed $entity
42
     * @return bool
43
     * @throws RuntimeException
44
     */
45
    public function isPersisted($entity)
46
    {
47
        $this->validateEntity($entity);
48
        $entityDefinition = $this->definitions->getDefinition($entity);
49
50
        return $entityDefinition->getIdentityStrategy()->isIdentified($entity);
51
52
    }
53
54
    /**
55
     * @param $entity
56
     * @return mixed
57
     * @throws RuntimeException
58
     */
59
    public function getIdentity($entity)
60
    {
61
        $this->validateEntity($entity);
62
        $entityDefinition = $this->definitions->getDefinition($entity);
63
64
        return $entityDefinition->getIdentityStrategy()->getIdentity($entity);
65
    }
66
67
    /**
68
     * @param $entity
69
     * @throws RuntimeException
70
     */
71
    private function validateEntity($entity)
72
    {
73
        if (!$this->definitions->hasDefinition($entity)) {
74
            throw new RuntimeException(sprintf("Class \"%s\" does not have definition.", get_class($entity)));
75
        }
76
    }
77
}
78