| @@ 74-87 (lines=14) @@ | ||
| 71 | } |
|
| 72 | } |
|
| 73 | ||
| 74 | public function all(): array |
|
| 75 | { |
|
| 76 | $data = []; |
|
| 77 | ||
| 78 | $class = new ReflectionClass(static::class); |
|
| 79 | ||
| 80 | $properties = $class->getProperties(ReflectionProperty::IS_PUBLIC); |
|
| 81 | ||
| 82 | foreach ($properties as $reflectionProperty) { |
|
| 83 | $data[$reflectionProperty->getName()] = $reflectionProperty->getValue($this); |
|
| 84 | } |
|
| 85 | ||
| 86 | return $data; |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * @param string ...$keys |
|
| @@ 159-171 (lines=13) @@ | ||
| 156 | */ |
|
| 157 | private function getFieldValidators(): array |
|
| 158 | { |
|
| 159 | return DTOCache::resolve(static::class, function () { |
|
| 160 | $class = new ReflectionClass(static::class); |
|
| 161 | ||
| 162 | $properties = []; |
|
| 163 | ||
| 164 | foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $reflectionProperty) { |
|
| 165 | $field = $reflectionProperty->getName(); |
|
| 166 | ||
| 167 | $properties[$field] = FieldValidator::fromReflection($reflectionProperty); |
|
| 168 | } |
|
| 169 | ||
| 170 | return $properties; |
|
| 171 | }); |
|
| 172 | } |
|
| 173 | } |
|
| 174 | ||