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

Association::isOk()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 6
eloc 10
nc 4
nop 0
1
<?php
2
3
namespace AlgoWeb\PODataLaravel\Models;
4
5
class Association
6
{
7
    /**
8
     * @var AssociationStubBase
9
     */
10
    protected $first;
11
12
    /**
13
     * @var AssociationStubBase
14
     */
15
    protected $last;
16
17
    /**
18
     * @return AssociationStubBase
19
     */
20
    public function getFirst()
21
    {
22
        return $this->first;
23
    }
24
25
    /**
26
     * @param AssociationStubBase $first
27
     */
28
    public function setFirst(AssociationStubBase $first)
29
    {
30
        $this->first = $first;
31
    }
32
33
    /**
34
     * @return AssociationStubBase
35
     */
36
    public function getLast()
37
    {
38
        return $this->last;
39
    }
40
41
    /**
42
     * @param AssociationStubBase $last
43
     */
44
    public function setLast(AssociationStubBase $last)
45
    {
46
        $this->last = $last;
47
    }
48
49
    public function isOk()
50
    {
51
        $first = $this->getFirst();
52
        $last = $this->getLast();
53
        if (null === $first || !$first->isOk()) {
54
            return false;
55
        }
56
        if (null === $last || !$last->isOk()) {
57
            return false;
58
        }
59
        if (!$first->isCompatible($last)) {
60
            return false;
61
        }
62
        return -1 === $first->compare($last);
63
    }
64
}
65