Completed
Pull Request — master (#42)
by Jasper
03:02
created

MorphToRelation::dissociate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Swis\JsonApi\Client\Relations;
4
5
use Swis\JsonApi\Client\Interfaces\DataInterface;
6
7
class MorphToRelation extends AbstractOneRelation
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12 35
    public function associate(DataInterface $included)
13
    {
14 35
        parent::associate($included);
15
16
        /* @var \Swis\JsonApi\Client\Interfaces\ItemInterface $included */
17
18 35
        $this->type = $included->getType();
19
20 35
        return $this;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 5
    public function dissociate()
27
    {
28 5
        parent::dissociate();
29
30 5
        $this->type = null;
31
32 5
        return $this;
33
    }
34
}
35