| @@ 87-100 (lines=14) @@ | ||
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | public function all(): array |
|
| 88 | { |
|
| 89 | $data = []; |
|
| 90 | ||
| 91 | $class = new ReflectionClass(static::class); |
|
| 92 | ||
| 93 | $properties = $class->getProperties(ReflectionProperty::IS_PUBLIC); |
|
| 94 | ||
| 95 | foreach ($properties as $reflectionProperty) { |
|
| 96 | $data[$reflectionProperty->getName()] = $reflectionProperty->getValue($this); |
|
| 97 | } |
|
| 98 | ||
| 99 | return $data; |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @param string ...$keys |
|
| @@ 172-189 (lines=18) @@ | ||
| 169 | */ |
|
| 170 | protected function getFieldValidators(): array |
|
| 171 | { |
|
| 172 | return DTOCache::resolve(static::class, function () { |
|
| 173 | $class = new ReflectionClass(static::class); |
|
| 174 | ||
| 175 | $properties = []; |
|
| 176 | ||
| 177 | foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $reflectionProperty) { |
|
| 178 | // Skip static properties |
|
| 179 | if ($reflectionProperty->isStatic()) { |
|
| 180 | continue; |
|
| 181 | } |
|
| 182 | ||
| 183 | $field = $reflectionProperty->getName(); |
|
| 184 | ||
| 185 | $properties[$field] = FieldValidator::fromReflection($reflectionProperty); |
|
| 186 | } |
|
| 187 | ||
| 188 | return $properties; |
|
| 189 | }); |
|
| 190 | } |
|
| 191 | ||
| 192 | /** |
|