| Total Complexity | 7 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | trait PropertyHandler |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @param array $data |
||
| 16 | */ |
||
| 17 | function fillProperties(array $data) |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param string $property |
||
| 27 | * @param mixed $value |
||
| 28 | */ |
||
| 29 | function fillProperty(string $property, $value) |
||
| 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 | |||
| 39 | /** |
||
| 40 | * @return array |
||
| 41 | */ |
||
| 42 | function getPropertyArray(): array |
||
| 56 | } |
||
| 57 | |||
| 59 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.