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