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

AbstractRelation   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 15
dl 0
loc 73
ccs 15
cts 15
cp 1
rs 10
c 3
b 1
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldOmitIncluded() 0 3 1
A hasIncluded() 0 3 1
A hasData() 0 3 1
A hasAssociated() 0 3 2
A dissociate() 0 6 1
A setOmitIncluded() 0 5 1
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