| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public static function get($object, $property) |
||
| 16 | { |
||
| 17 | if (array_key_exists($property, get_object_vars($object))) { |
||
| 18 | return $object->{$property}; |
||
| 19 | } |
||
| 20 | |||
| 21 | if (method_exists(get_class($object), $property)) { |
||
| 22 | return $object->{$property}(); |
||
| 23 | } |
||
| 24 | |||
| 25 | if (method_exists(get_class($object), 'get'.$property)) { |
||
| 26 | $property = 'get'.$property; |
||
| 27 | |||
| 28 | return $object->{$property}(); |
||
| 29 | } |
||
| 30 | |||
| 31 | throw new \Exception( |
||
| 32 | sprintf( |
||
| 33 | 'Could not filter by property \'%s\' as it does not exist in object %s.', |
||
| 34 | $property, |
||
| 35 | get_class($object) |
||
| 36 | ) |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |