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