| Total Complexity | 12 |
| Total Lines | 114 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 14 | final class Relation |
||
| 15 | { |
||
| 16 | /** @var OptionMap */ |
||
| 17 | private $options; |
||
| 18 | |||
| 19 | /** @var string */ |
||
| 20 | private $type; |
||
| 21 | |||
| 22 | /** @var string */ |
||
| 23 | private $target; |
||
| 24 | |||
| 25 | /** @var string|null */ |
||
| 26 | private $inverse = null; |
||
| 27 | |||
| 28 | /** @var string|null */ |
||
| 29 | private $inverseType = null; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Relation constructor. |
||
| 33 | */ |
||
| 34 | public function __construct() |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return OptionMap |
||
| 41 | */ |
||
| 42 | public function getOptions(): OptionMap |
||
| 43 | { |
||
| 44 | return $this->options; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $type |
||
| 49 | * @return Relation |
||
| 50 | */ |
||
| 51 | public function setType(string $type): Relation |
||
| 52 | { |
||
| 53 | $this->type = $type; |
||
| 54 | |||
| 55 | return $this; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function getType(): string |
||
| 62 | { |
||
| 63 | if ($this->type === null) { |
||
| 64 | throw new RelationException("Relation type must be set"); |
||
| 65 | } |
||
| 66 | |||
| 67 | return $this->type; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string $target |
||
| 72 | * @return Relation |
||
| 73 | */ |
||
| 74 | public function setTarget(string $target): Relation |
||
| 75 | { |
||
| 76 | $this->target = $target; |
||
| 77 | |||
| 78 | return $this; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | public function getTarget(): string |
||
| 85 | { |
||
| 86 | if ($this->target === null) { |
||
| 87 | throw new RelationException("Relation target must be set"); |
||
| 88 | } |
||
| 89 | |||
| 90 | return $this->target; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @param string $into |
||
| 95 | * @param string $as |
||
| 96 | * @return Relation |
||
| 97 | */ |
||
| 98 | public function setInverse(string $into, string $as): Relation |
||
| 99 | { |
||
| 100 | $this->inverse = $into; |
||
| 101 | $this->inverseType = $as; |
||
| 102 | |||
| 103 | return $this; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return bool |
||
| 108 | */ |
||
| 109 | public function isInversed(): bool |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @return string|null |
||
| 116 | */ |
||
| 117 | public function getInverseName(): ?string |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @return string|null |
||
| 124 | */ |
||
| 125 | public function getInverseType(): ?string |
||
| 128 | } |
||
| 129 | } |