Total Complexity | 9 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 7 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class AssociationStubPolymorphic extends AssociationStubBase |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $morphType; |
||
15 | |||
16 | /** |
||
17 | * @return string |
||
18 | */ |
||
19 | public function getMorphType(): ?string |
||
20 | { |
||
21 | return $this->morphType; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param string $morphType |
||
26 | */ |
||
27 | public function setMorphType(string $morphType): void |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param \AlgoWeb\PODataLaravel\Models\ObjectMap\Entities\Associations\AssociationStubBase $otherStub |
||
34 | * |
||
35 | * @return bool |
||
36 | */ |
||
37 | public function isCompatible(AssociationStubBase $otherStub): bool |
||
38 | { |
||
39 | if (!parent::isCompatible($otherStub)) { |
||
40 | return false; |
||
41 | } |
||
42 | |||
43 | if (null === $this->getTargType() && null === $otherStub->getTargType()) { |
||
44 | return false; |
||
45 | } |
||
46 | |||
47 | $thisBase = $this->getBaseType(); |
||
48 | $thatBase = $otherStub->getBaseType(); |
||
49 | $thatTarg = $otherStub->getTargType() ?? $thisBase; |
||
50 | $thisTarg = $this->getTargType() ?? $thatBase; |
||
51 | if ($thatTarg != $thisBase) { |
||
52 | return false; |
||
53 | } |
||
54 | if ($thisTarg != $thatBase) { |
||
55 | return false; |
||
56 | } |
||
57 | |||
58 | return true; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function morphicType(): string |
||
67 | } |
||
68 | } |
||
69 |