Relation::getTargetEntity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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