Completed
Push — master ( 5d2be1...68f0c9 )
by Dominik
01:57
created

ModelReference::getModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Model\Reference;
6
7
use Chubbyphp\Model\ModelInterface;
8
9
final class ModelReference implements ModelReferenceInterface
10
{
11
    /**
12
     * @var string|null
13
     */
14
    private $id;
15
16
    /**
17
     * @var ModelInterface|null
18
     */
19
    private $model;
20
21
    /**
22
     * @param ModelInterface|null $model
23
     * @return ModelReferenceInterface
24
     */
25 View Code Duplication
    public function setModel(ModelInterface $model = null): ModelReferenceInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $this->model = $model;
28
        $this->id = null !== $model ? $model->getId() : null;
29
30
        return $this;
31
    }
32
33
    /**
34
     * @return ModelInterface|null
35
     */
36
    public function getModel()
37
    {
38
        return $this->model;
39
    }
40
41
    /**
42
     * @return null|string
43
     */
44
    public function getId()
45
    {
46
        return $this->id;
47
    }
48
49
    /**
50
     * @return ModelInterface|null
51
     */
52
    public function getInitialModel()
53
    {
54
        return null;
55
    }
56
57
    /**
58
     * @return array|null
59
     */
60
    public function jsonSerialize()
61
    {
62
        if (null === $this->model) {
63
            return null;
64
        }
65
66
        return $this->model->jsonSerialize();
67
    }
68
}
69