Field   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 127
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 1
dl 0
loc 127
rs 10
c 0
b 0
f 0

9 Methods

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