|
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\Translation; |
|
11
|
|
|
|
|
12
|
|
|
use FAPI\PhraseApp\Model\CreatableFromArray; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @author Sascha-Oliver Prolic <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class Key implements CreatableFromArray |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
private $id; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $name; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var bool |
|
31
|
|
|
*/ |
|
32
|
|
|
private $plural; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $dataType; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
private $tags = []; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param array $data |
|
46
|
|
|
* |
|
47
|
|
|
* @return Key |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function createFromArray(array $data) |
|
50
|
|
|
{ |
|
51
|
|
|
$self = new self(); |
|
52
|
|
|
|
|
53
|
|
|
if (isset($data['id'])) { |
|
54
|
|
|
$self->setId($data['id']); |
|
55
|
|
|
} |
|
56
|
|
|
if (isset($data['name'])) { |
|
57
|
|
|
$self->setName($data['name']); |
|
58
|
|
|
} |
|
59
|
|
|
if (isset($data['plural'])) { |
|
60
|
|
|
$self->setPlural($data['plural']); |
|
61
|
|
|
} |
|
62
|
|
|
if (isset($data['data_type'])) { |
|
63
|
|
|
$self->setDataType($data['data_type']); |
|
64
|
|
|
} |
|
65
|
|
|
if (isset($data['tags'])) { |
|
66
|
|
|
$self->setTags($data['tags']); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return $self; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getId(): string |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->id; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
private function setId(string $id) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->id = $id; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getName(): string |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->name; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
private function setName(string $name) |
|
88
|
|
|
{ |
|
89
|
|
|
$this->name = $name; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function isPlural(): bool |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->plural; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
private function setPlural(bool $plural) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->plural = $plural; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function getDataType(): string |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->dataType; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
private function setDataType(string $dataType) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->dataType = $dataType; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function getTags(): array |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->tags; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
private function setTags(array $tags) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->tags = $tags; |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|