AbstractRelation   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 112
    public function hasData(): bool
31
    {
32 112
        return $this->data !== false;
33
    }
34
35 188
    public function hasIncluded(): bool
36
    {
37 188
        return $this->included !== false;
38
    }
39
40
    /**
41
     * @return $this
42
     */
43 192
    public function dissociate()
44
    {
45 192
        $this->data = null;
46 192
        $this->included = null;
47
48 192
        return $this;
49
    }
50
51 112
    public function hasAssociated(): bool
52
    {
53 112
        return $this->hasData() || $this->hasIncluded();
54
    }
55
56
    /**
57
     * @return $this
58
     */
59 12
    public function setOmitIncluded(bool $omitIncluded)
60
    {
61 12
        $this->omitIncluded = $omitIncluded;
62
63 12
        return $this;
64
    }
65
66 48
    public function shouldOmitIncluded(): bool
67
    {
68 48
        return $this->omitIncluded;
69
    }
70
}
71