| @@ 92-110 (lines=19) @@ | ||
| 89 | return false; |
|
| 90 | } |
|
| 91 | ||
| 92 | public function all(): array |
|
| 93 | { |
|
| 94 | $data = []; |
|
| 95 | ||
| 96 | $class = new ReflectionClass(static::class); |
|
| 97 | ||
| 98 | $properties = $class->getProperties(ReflectionProperty::IS_PUBLIC); |
|
| 99 | ||
| 100 | foreach ($properties as $reflectionProperty) { |
|
| 101 | // Skip static properties |
|
| 102 | if ($reflectionProperty->isStatic()) { |
|
| 103 | continue; |
|
| 104 | } |
|
| 105 | ||
| 106 | $data[$reflectionProperty->getName()] = $reflectionProperty->getValue($this); |
|
| 107 | } |
|
| 108 | ||
| 109 | return $data; |
|
| 110 | } |
|
| 111 | ||
| 112 | public function only(string ...$keys): DataTransferObjectArray |
|
| 113 | { |
|
| @@ 156-173 (lines=18) @@ | ||
| 153 | */ |
|
| 154 | protected function getFieldValidators(): array |
|
| 155 | { |
|
| 156 | return DTOCache::resolve(static::class, function () { |
|
| 157 | $class = new ReflectionClass(static::class); |
|
| 158 | ||
| 159 | $properties = []; |
|
| 160 | ||
| 161 | foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $reflectionProperty) { |
|
| 162 | // Skip static properties |
|
| 163 | if ($reflectionProperty->isStatic()) { |
|
| 164 | continue; |
|
| 165 | } |
|
| 166 | ||
| 167 | $field = $reflectionProperty->getName(); |
|
| 168 | ||
| 169 | $properties[$field] = FieldValidator::fromReflection($reflectionProperty); |
|
| 170 | } |
|
| 171 | ||
| 172 | return $properties; |
|
| 173 | }); |
|
| 174 | } |
|
| 175 | ||
| 176 | /** |
|