@@ -11,48 +11,48 @@ |
||
| 11 | 11 | |
| 12 | 12 | trait PropertyHandler |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * @param array $data |
|
| 16 | - */ |
|
| 14 | + /** |
|
| 15 | + * @param array $data |
|
| 16 | + */ |
|
| 17 | 17 | function fillProperties(array $data): void |
| 18 | - { |
|
| 19 | - foreach ($data as $p => $v) |
|
| 20 | - { |
|
| 21 | - $this->fillProperty($p, $v); |
|
| 22 | - } |
|
| 23 | - } |
|
| 18 | + { |
|
| 19 | + foreach ($data as $p => $v) |
|
| 20 | + { |
|
| 21 | + $this->fillProperty($p, $v); |
|
| 22 | + } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param string $property |
|
| 27 | - * @param mixed $value |
|
| 28 | - */ |
|
| 25 | + /** |
|
| 26 | + * @param string $property |
|
| 27 | + * @param mixed $value |
|
| 28 | + */ |
|
| 29 | 29 | function fillProperty(string $property, $value): void |
| 30 | - { |
|
| 31 | - $property = lcfirst(str_replace('_', '', ucwords($property, '_'))); |
|
| 32 | - if(property_exists(__CLASS__, $property)) |
|
| 33 | - { |
|
| 34 | - $method = sprintf('set%s', ucfirst($property)); |
|
| 35 | - $this->{$method}($value); |
|
| 36 | - } |
|
| 37 | - } |
|
| 30 | + { |
|
| 31 | + $property = lcfirst(str_replace('_', '', ucwords($property, '_'))); |
|
| 32 | + if(property_exists(__CLASS__, $property)) |
|
| 33 | + { |
|
| 34 | + $method = sprintf('set%s', ucfirst($property)); |
|
| 35 | + $this->{$method}($value); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return array |
|
| 41 | - */ |
|
| 42 | - function getPropertyArray(): array |
|
| 43 | - { |
|
| 44 | - $reflection = new \ReflectionClass(__CLASS__); |
|
| 45 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); |
|
| 46 | - $data = []; |
|
| 47 | - foreach($properties as $property){ |
|
| 48 | - $prop_name = $property->getName(); |
|
| 49 | - $method = sprintf('get%s', ucfirst($prop_name)); |
|
| 50 | - $form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); |
|
| 51 | - if($reflection->hasMethod($method)){ |
|
| 52 | - $data[$form_name] = $this->{$method}(); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - return $data; |
|
| 56 | - } |
|
| 39 | + /** |
|
| 40 | + * @return array |
|
| 41 | + */ |
|
| 42 | + function getPropertyArray(): array |
|
| 43 | + { |
|
| 44 | + $reflection = new \ReflectionClass(__CLASS__); |
|
| 45 | + $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); |
|
| 46 | + $data = []; |
|
| 47 | + foreach($properties as $property){ |
|
| 48 | + $prop_name = $property->getName(); |
|
| 49 | + $method = sprintf('get%s', ucfirst($prop_name)); |
|
| 50 | + $form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); |
|
| 51 | + if($reflection->hasMethod($method)){ |
|
| 52 | + $data[$form_name] = $this->{$method}(); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + return $data; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | } |