Relation   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 74
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getSerializedKey() 0 3 1
A setSerializedKey() 0 5 1
A setType() 0 5 1
A setTargetEntity() 0 5 1
A isOneToMany() 0 3 1
A isManyToOne() 0 3 1
A getTargetEntity() 0 3 1
A __construct() 0 8 1
A getType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Mapado\RestClientSdk\Mapping;
6
7
/**
8
 * Class Relation
9
 *
10
 * @author Julien Deniau <[email protected]>
11
 */
12
class Relation
13
{
14
    public const MANY_TO_ONE = 'ManyToOne';
15
    public const ONE_TO_MANY = 'OneToMany';
16
17
    /**
18
     * @var string
19
     */
20
    private $serializedKey;
21
22
    /**
23
     * @var string
24
     */
25
    private $type;
26
27
    /**
28
     * @var string
29
     */
30
    private $targetEntity;
31
32
    public function __construct(
33
        string $serializedKey,
34
        string $type,
35
        string $targetEntity
36
    ) {
37
        $this->serializedKey = $serializedKey;
38
        $this->type = $type;
39
        $this->targetEntity = $targetEntity;
40
    }
41
42
    public function getSerializedKey(): string
43
    {
44
        return $this->serializedKey;
45
    }
46
47
    public function setSerializedKey(string $serializedKey): self
48
    {
49
        $this->serializedKey = $serializedKey;
50
51
        return $this;
52
    }
53
54
    public function getType(): string
55
    {
56
        return $this->type;
57
    }
58
59
    public function setType(string $type): self
60
    {
61
        $this->type = $type;
62
63
        return $this;
64
    }
65
66
    public function isOneToMany(): bool
67
    {
68
        return self::ONE_TO_MANY === $this->getType();
69
    }
70
71
    public function isManyToOne(): bool
72
    {
73
        return self::MANY_TO_ONE === $this->getType();
74
    }
75
76
    public function getTargetEntity(): string
77
    {
78
        return $this->targetEntity;
79
    }
80
81
    public function setTargetEntity(string $targetEntity): self
82
    {
83
        $this->targetEntity = $targetEntity;
84
85
        return $this;
86
    }
87
}
88