Completed
Pull Request — master (#52)
by Jasper
04:02
created

AbstractOneRelation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A associate() 0 5 1
A getIncluded() 0 3 1
A hasIncluded() 0 3 1
1
<?php
2
3
namespace Swis\JsonApi\Client\Relations;
4
5
use Swis\JsonApi\Client\Interfaces\ItemInterface;
6
use Swis\JsonApi\Client\Interfaces\OneRelationInterface;
7
8
/**
9
 * @property \Swis\JsonApi\Client\Interfaces\ItemInterface|null $included
10
 */
11
abstract class AbstractOneRelation extends AbstractRelation implements OneRelationInterface
12
{
13
    /**
14
     * @param \Swis\JsonApi\Client\Interfaces\ItemInterface $included
15
     *
16
     * @return $this
17
     */
18 110
    public function associate(ItemInterface $included)
19
    {
20 110
        $this->included = $included;
21
22 110
        return $this;
23
    }
24
25
    /**
26
     * @return \Swis\JsonApi\Client\Interfaces\ItemInterface|null
27
     */
28 110
    public function getIncluded(): ? ItemInterface
29
    {
30 110
        return $this->included;
31
    }
32
33
    /**
34
     * @return bool
35
     */
36 35
    public function hasIncluded(): bool
37
    {
38 35
        return null !== $this->getIncluded();
39
    }
40
}
41