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