Completed
Push — master ( 08753a...42665f )
by Sascha-Oliver
05:38
created

KeySearchResult::createFromArray()   F

Complexity

Conditions 9
Paths 256

Size

Total Lines 31
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 0
cts 29
cp 0
rs 3
c 0
b 0
f 0
cc 9
eloc 19
nc 256
nop 1
crap 90
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license.  See the LICENSE file for details.
8
 */
9
10
namespace FAPI\PhraseApp\Model\Key;
11
12
use FAPI\PhraseApp\Model\CreatableFromArray;
13
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17
class KeySearchResult implements CreatableFromArray
18
{
19
    /**
20
     * @var string
21
     */
22
    private $id;
23
24
    /**
25
     * @var string
26
     */
27
    private $name;
28
29
    /**
30
     * @var string
31
     */
32
    private $description;
33
34
    /**
35
     * @var string
36
     */
37
    private $nameHash;
38
39
    /**
40
     * @var bool
41
     */
42
    private $plural;
43
44
    /**
45
     * @var array
46
     */
47
    private $tags = [];
48
49
    /**
50
     * @var string
51
     */
52
    private $createdAt;
53
54
    /**
55
     * @var string
56
     */
57
    private $updatedAt;
58
59
    /**
60
     * @param array $data
61
     *
62
     * @return KeySearchResult
63
     */
64
    public static function createFromArray(array $data)
65
    {
66
        $self = new self();
67
68
        if (isset($data['id'])) {
69
            $self->setId($data['id']);
70
        }
71
        if (isset($data['name'])) {
72
            $self->setName($data['name']);
73
        }
74
        if (isset($data['description'])) {
75
            $self->setDescription($data['description']);
76
        }
77
        if (isset($data['name_hash'])) {
78
            $self->setNameHash($data['name_hash']);
79
        }
80
        if (isset($data['plural'])) {
81
            $self->setPlural($data['plural']);
82
        }
83
        if (isset($data['tags'])) {
84
            $self->setTags($data['tags']);
85
        }
86
        if (isset($data['created_at'])) {
87
            $self->setCreatedAt($data['created_at']);
88
        }
89
        if (isset($data['updated_at'])) {
90
            $self->setUpdatedAt($data['updated_at']);
91
        }
92
93
        return $self;
94
    }
95
96
    public function getId(): string
97
    {
98
        return $this->id;
99
    }
100
101
    private function setId(string $id)
102
    {
103
        $this->id = $id;
104
    }
105
106
    public function getName(): string
107
    {
108
        return $this->name;
109
    }
110
111
    private function setName(string $name)
112
    {
113
        $this->name = $name;
114
    }
115
116
    public function isPlural(): bool
117
    {
118
        return $this->plural;
119
    }
120
121
    private function setPlural(bool $plural)
122
    {
123
        $this->plural = $plural;
124
    }
125
126
    public function getTags(): array
127
    {
128
        return $this->tags;
129
    }
130
131
    private function setTags(array $tags)
132
    {
133
        $this->tags = $tags;
134
    }
135
136
    public function getDescription(): string
137
    {
138
        return $this->description;
139
    }
140
141
    private function setDescription(string $description)
142
    {
143
        $this->description = $description;
144
    }
145
146
    public function getNameHash(): string
147
    {
148
        return $this->nameHash;
149
    }
150
151
    private function setNameHash(string $nameHash)
152
    {
153
        $this->nameHash = $nameHash;
154
    }
155
156
    public function getCreatedAt(): string
157
    {
158
        return $this->createdAt;
159
    }
160
161
    private function setCreatedAt(string $createdAt)
162
    {
163
        $this->createdAt = $createdAt;
164
    }
165
166
    public function getUpdatedAt(): string
167
    {
168
        return $this->updatedAt;
169
    }
170
171
    private function setUpdatedAt(string $updatedAt)
172
    {
173
        $this->updatedAt = $updatedAt;
174
    }
175
}
176