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

MorphToRelation::__construct()   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
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
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