Completed
Push — master ( 8f5342...8c413c )
by Jasper
15s queued 12s
created

AbstractRelation::hasData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swis\JsonApi\Client\Relations;
6
7
use Swis\JsonApi\Client\Concerns\HasLinks;
8
use Swis\JsonApi\Client\Concerns\HasMeta;
9
10
abstract class AbstractRelation
11
{
12
    use HasLinks;
13
    use HasMeta;
14
15
    /**
16
     * @var \Swis\JsonApi\Client\Interfaces\DataInterface|false|null
17
     */
18
    protected $data = false;
19
20
    /**
21
     * @var \Swis\JsonApi\Client\Interfaces\DataInterface|false|null
22
     */
23
    protected $included = false;
24
25
    /**
26
     * @var bool
27
     */
28
    protected $omitIncluded = false;
29
30
    /**
31
     * @return bool
32
     */
33 112
    public function hasData(): bool
34
    {
35 112
        return $this->data !== false;
36
    }
37
38
    /**
39
     * @return bool
40
     */
41 188
    public function hasIncluded(): bool
42
    {
43 188
        return $this->included !== false;
44
    }
45
46
    /**
47
     * @return $this
48
     */
49 192
    public function dissociate()
50
    {
51 192
        $this->data = null;
52 192
        $this->included = null;
53
54 192
        return $this;
55
    }
56
57
    /**
58
     * @return bool
59
     */
60 112
    public function hasAssociated(): bool
61
    {
62 112
        return $this->hasData() || $this->hasIncluded();
63
    }
64
65
    /**
66
     * @param bool $omitIncluded
67
     *
68
     * @return $this
69
     */
70 12
    public function setOmitIncluded(bool $omitIncluded)
71
    {
72 12
        $this->omitIncluded = $omitIncluded;
73
74 12
        return $this;
75
    }
76
77
    /**
78
     * @return bool
79
     */
80 48
    public function shouldOmitIncluded(): bool
81
    {
82 48
        return $this->omitIncluded;
83
    }
84
}
85