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.

PropertyValue::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Isolate\UnitOfWork\Entity\Definition\IdentificationStrategy;
4
5
use Isolate\UnitOfWork\Entity\Definition\IdentificationStrategy;
6
use Isolate\UnitOfWork\Entity\Definition\Identity;
7
use Isolate\UnitOfWork\Exception\RuntimeException;
8
use Isolate\UnitOfWork\Object\PropertyAccessor;
9
10
class PropertyValue implements IdentificationStrategy
11
{
12
    /**
13
     * @var Identity
14
     */
15
    private $identity;
16
17
    /**
18
     * @var PropertyAccessor
19
     */
20
    private $propertyAccessor;
21
22
    /**
23
     * @param Identity $identity
24
     */
25
    public function __construct(Identity $identity)
26
    {
27
        $this->identity = $identity;
28
        $this->propertyAccessor = new PropertyAccessor();
29
    }
30
31
    /**
32
     * @param mixed $entity
33
     * @return boolean
34
     */
35
    public function isIdentified($entity)
36
    {
37
        $identity = $this->propertyAccessor->getValue($entity, $this->identity->getPropertyName());
38
39
        return !empty($identity) || $identity === 0;
40
    }
41
42
    /**
43
     * @param $entity
44
     * @return mixed
45
     * @throws RuntimeException
46
     */
47
    public function getIdentity($entity)
48
    {
49
        $identity = $this->propertyAccessor->getValue($entity, $this->identity->getPropertyName());
50
51
        if (empty($identity) && $identity !== 0) {
52
            throw new RuntimeException("Can't get identity from not identified entity.");
53
        }
54
55
        return $identity;
56
    }
57
}
58