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.

Association::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace Isolate\UnitOfWork\Entity\Definition;
4
5
use Isolate\UnitOfWork\Entity\ClassName;
6
use Isolate\UnitOfWork\Exception\InvalidArgumentException;
7
8
/**
9
 * @api
10
 */
11
final class Association
12
{
13
    /**
14
     * Entity to other entity
15
     */
16
    const TO_SINGLE_ENTITY = 0;
17
18
    /**
19
     * Entity to many entities
20
     */
21
    const TO_MANY_ENTITIES = 1;
22
23
    /**
24
     * @var ClassName
25
     */
26
    private $target;
27
28
    /**
29
     * @var int
30
     */
31
    private $type;
32
33
    /**
34
     * @param ClassName $target
35
     * @param $type
36
     * @throws InvalidArgumentException
37
     */
38
    public function __construct(ClassName $target, $type)
39
    {
40
        $this->validateAssociationType($type);
41
42
        $this->target = $target;
43
        $this->type = $type;
44
    }
45
46
    /**
47
     * @return ClassName
48
     * 
49
     * @api
50
     */
51
    public function getTargetClassName()
52
    {
53
        return $this->target;
54
    }
55
56
    /**
57
     * @return int
58
     * 
59
     * @api
60
     */
61
    public function getType()
62
    {
63
        return $this->type;
64
    }
65
66
    /**
67
     * @param $type
68
     * @throws InvalidArgumentException
69
     */
70
    private function validateAssociationType($type)
71
    {
72
        if ($type != self::TO_SINGLE_ENTITY && $type != self::TO_MANY_ENTITIES) {
73
            throw new InvalidArgumentException("Unknown association type.");
74
        }
75
    }
76
}
77