1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Micro framework package. |
7
|
|
|
* |
8
|
|
|
* (c) Stanislau Komar <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Micro\Library\DTO\ClassDef; |
15
|
|
|
|
16
|
|
|
class PropertyDefinition |
17
|
|
|
{ |
18
|
|
|
private string $name; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string[] |
22
|
|
|
*/ |
23
|
|
|
private array $comments = []; |
24
|
|
|
/** |
25
|
|
|
* @var string[] |
26
|
|
|
*/ |
27
|
|
|
private array $types = []; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var array<array<string, mixed>> |
31
|
|
|
*/ |
32
|
|
|
private array $attributes = []; |
33
|
|
|
|
34
|
|
|
private bool $isRequired = false; |
35
|
|
|
private bool $isCollection = false; |
36
|
|
|
|
37
|
3 |
|
public function __construct() |
38
|
|
|
{ |
39
|
3 |
|
$this->name = ''; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
3 |
|
public function getName(): string |
46
|
|
|
{ |
47
|
3 |
|
return $this->name; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param string $name |
52
|
|
|
*/ |
53
|
3 |
|
public function setName(string $name): void |
54
|
|
|
{ |
55
|
3 |
|
$this->name = $name; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return string[] |
60
|
|
|
*/ |
61
|
1 |
|
public function getComments(): array |
62
|
|
|
{ |
63
|
1 |
|
return $this->comments; |
64
|
|
|
} |
65
|
|
|
|
66
|
1 |
|
public function addComment(string $comment): self |
67
|
|
|
{ |
68
|
1 |
|
$this->comments[] = $comment; |
69
|
|
|
|
70
|
1 |
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string[] |
75
|
|
|
*/ |
76
|
1 |
|
public function getTypes(): array |
77
|
|
|
{ |
78
|
1 |
|
return $this->types; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param string[] $types |
83
|
|
|
*/ |
84
|
1 |
|
public function setTypes(array $types): void |
85
|
|
|
{ |
86
|
1 |
|
$this->types = $types; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return bool |
91
|
|
|
*/ |
92
|
1 |
|
public function isRequired(): bool |
93
|
|
|
{ |
94
|
1 |
|
return $this->isRequired; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param bool $isRequired |
99
|
|
|
*/ |
100
|
3 |
|
public function setIsRequired(bool $isRequired): void |
101
|
|
|
{ |
102
|
3 |
|
$this->isRequired = $isRequired; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
1 |
|
public function isCollection(): bool |
109
|
|
|
{ |
110
|
1 |
|
return $this->isCollection; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param bool $isCollection |
115
|
|
|
*/ |
116
|
1 |
|
public function setIsCollection(bool $isCollection): void |
117
|
|
|
{ |
118
|
1 |
|
$this->isCollection = $isCollection; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param string $attributeName |
123
|
|
|
* @param array<string, mixed> $arguments |
124
|
|
|
* |
125
|
|
|
* @return $this |
126
|
|
|
*/ |
127
|
1 |
|
public function addAttribute(string $attributeName, array $arguments): self |
128
|
|
|
{ |
129
|
1 |
|
$this->attributes[] = [ |
130
|
1 |
|
$attributeName => $arguments, |
131
|
1 |
|
]; |
132
|
|
|
|
133
|
1 |
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return array<string, mixed> |
138
|
|
|
*/ |
139
|
1 |
|
public function getAttributes(): array |
140
|
|
|
{ |
141
|
1 |
|
return $this->attributes; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|