Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
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 | } |
||
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.