1 | <?php |
||
8 | final class Property implements ArrayAccess |
||
9 | { |
||
10 | const IMMUTABLE = 'immutable'; |
||
11 | const MUTABLE_CREATE_ONLY = 'mutable_create_only'; |
||
12 | const MUTABLE = 'mutable'; |
||
13 | |||
14 | /** @var string */ |
||
15 | private $name; |
||
16 | |||
17 | /** @var string|null */ |
||
18 | private $type = null; |
||
19 | |||
20 | /** @var string */ |
||
21 | private $mutable = self::MUTABLE; |
||
22 | |||
23 | /** @var bool */ |
||
24 | private $null = false; |
||
25 | |||
26 | /** @var bool */ |
||
27 | private $required = false; |
||
28 | |||
29 | /** @var callable|string|null */ |
||
30 | private $validate = null; |
||
31 | |||
32 | /** @var mixed|null */ |
||
33 | private $default = null; |
||
34 | |||
35 | /** @var bool */ |
||
36 | private $hasDefault; |
||
37 | |||
38 | /** @var bool */ |
||
39 | private $encrypted = false; |
||
40 | |||
41 | /** @var bool */ |
||
42 | private $persisted = true; |
||
43 | |||
44 | /** @var string|null */ |
||
45 | private $relation; |
||
46 | |||
47 | /** @var string|null */ |
||
48 | private $relation_type; |
||
49 | |||
50 | /** @var string|null */ |
||
51 | private $foreign_key; |
||
52 | |||
53 | /** @var string|null */ |
||
54 | private $local_key; |
||
55 | |||
56 | /** @var string|null */ |
||
57 | private $pivot_tablename; |
||
58 | |||
59 | public function __construct(array $values = [], string $name = '') |
||
67 | |||
68 | public function getName(): string |
||
72 | |||
73 | /** |
||
74 | * Gets the humanized name of this property. |
||
75 | */ |
||
76 | public function getTitle(Model $model): string |
||
90 | |||
91 | public function getType(): ?string |
||
95 | |||
96 | public function isMutable(): bool |
||
100 | |||
101 | public function isMutableCreateOnly(): bool |
||
105 | |||
106 | public function isImmutable(): bool |
||
110 | |||
111 | public function isNullable(): bool |
||
115 | |||
116 | public function isRequired(): bool |
||
117 | { |
||
118 | return $this->required; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @return callable|string|null |
||
123 | */ |
||
124 | public function getValidationRules() |
||
125 | { |
||
126 | return $this->validate; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function getDefault() |
||
133 | { |
||
134 | return $this->default; |
||
135 | } |
||
136 | |||
137 | public function hasDefault(): bool |
||
138 | { |
||
139 | return $this->hasDefault; |
||
140 | } |
||
141 | |||
142 | public function isPersisted(): bool |
||
143 | { |
||
144 | return $this->persisted; |
||
145 | } |
||
146 | |||
147 | public function isEncrypted(): bool |
||
148 | { |
||
149 | return $this->encrypted; |
||
150 | } |
||
151 | |||
152 | public function getForeignModelClass(): ?string |
||
153 | { |
||
154 | return $this->relation; |
||
155 | } |
||
156 | |||
157 | public function getRelationshipType(): ?string |
||
158 | { |
||
159 | return $this->relation_type; |
||
160 | } |
||
161 | |||
162 | public function getForeignKey(): ?string |
||
166 | |||
167 | public function getLocalKey(): ?string |
||
171 | |||
172 | public function getPivotTablename(): ?string |
||
176 | |||
177 | public function toArray(): array |
||
195 | |||
196 | public function offsetExists($offset) |
||
200 | |||
201 | public function offsetGet($offset) |
||
209 | |||
210 | public function offsetSet($offset, $value) |
||
214 | |||
215 | public function offsetUnset($offset) |
||
219 | } |
||
220 |