Test Failed
Pull Request — master (#115)
by Alex
03:29
created

AssociationStubPolymorphic::isCompatible()   B

Complexity

Conditions 7
Paths 5

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 7.551
c 0
b 0
f 0
cc 7
eloc 14
nc 5
nop 1
1
<?php
2
3
namespace AlgoWeb\PODataLaravel\Models;
4
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)
24
    {
25
        $this->morphType = $morphType;
26
    }
27
28
    public function isCompatible(AssociationStubBase $otherStub)
29
    {
30
        if (!parent::isCompatible($otherStub)) {
31
            return false;
32
        }
33
        $thisTarg = $this->getTargType();
34
        $thatTarg = $otherStub->getTargType();
35
        $thisNull = null === $thisTarg;
36
        $thatNull = null === $thatTarg;
37
        if ($thisNull == $thatNull) {
38
            return false;
39
        }
40
        if ($thisNull && ($thatTarg != $this->getBaseType())) {
41
            return false;
42
        }
43
        if ($thatNull && ($thisTarg != $otherStub->getBaseType())) {
1 ignored issue
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return !($thatNull && $t...erStub->getBaseType());.
Loading history...
44
            return false;
45
        }
46
47
        return true;
48
    }
49
}
50