Category::isEnabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Yproximite\Api\Model\Article;
5
6
use Yproximite\Api\Model\ModelInterface;
7
use Yproximite\Api\Model\Inheritance\InheritanceStatuses;
8
9
/**
10
 * Class Category
11
 */
12
class Category implements ModelInterface
13
{
14
    /**
15
     * @var int
16
     */
17
    private $id;
18
19
    /**
20
     * @var CategoryTranslation[]
21
     */
22
    private $translations;
23
24
    /**
25
     * @var bool
26
     */
27
    private $enabled;
28
29
    /**
30
     * @var int|null
31
     */
32
    private $dataParentId;
33
34
    /**
35
     * @var int|null
36
     */
37
    private $parentRootId;
38
39
    /**
40
     * @var \DateTime
41
     */
42
    private $createdAt;
43
44
    /**
45
     * @var \DateTime
46
     */
47
    private $updatedAt;
48
49
    /**
50
     * @var string
51
     */
52
    private $inheritanceStatus;
53
54
    /**
55
     * Category constructor.
56
     *
57
     * @param array $data
58
     */
59
    public function __construct(array $data)
60
    {
61
        $translations = array_map(function (array $data) {
62
            return new CategoryTranslation($data);
63
        }, $data['translations']);
64
65
        $this->id                = (int) $data['id'];
66
        $this->translations      = $translations;
67
        $this->enabled           = (bool) $data['enabled'];
68
        $this->dataParentId      = !empty($data['dataParent']) ? (int) $data['dataParent'] : null;
69
        $this->parentRootId      = (int) $data['parentRootId'];
70
        $this->createdAt         = new \DateTime($data['createdAt']['date']);
71
        $this->updatedAt         = new \DateTime($data['updatedAt']['date']);
72
        $this->inheritanceStatus = (string) $data['inheritance_status'];
73
    }
74
75
    public function getId(): int
76
    {
77
        return $this->id;
78
    }
79
80
    /**
81
     * @return CategoryTranslation[]
82
     */
83
    public function getTranslations(): array
84
    {
85
        return $this->translations;
86
    }
87
88
    public function isEnabled(): bool
89
    {
90
        return $this->enabled;
91
    }
92
93
    /**
94
     * @return int|null
95
     */
96
    public function getDataParentId()
97
    {
98
        return $this->dataParentId;
99
    }
100
101
    public function getCreatedAt(): \DateTime
102
    {
103
        return $this->createdAt;
104
    }
105
106
    public function getUpdatedAt(): \DateTime
107
    {
108
        return $this->updatedAt;
109
    }
110
111
    /**
112
     * @see InheritanceStatuses::getValues()
113
     *
114
     * @return string
115
     */
116
    public function getInheritanceStatus(): string
117
    {
118
        return $this->inheritanceStatus;
119
    }
120
121
    /**
122
     * @return int|null
123
     */
124
    public function getParentRootId()
125
    {
126
        return $this->parentRootId;
127
    }
128
129
    /**
130
     * @param int|null $parentRootId
131
     */
132
    public function setParentRootId($parentRootId)
133
    {
134
        $this->parentRootId = $parentRootId;
135
    }
136
}
137