@@ -62,7 +62,7 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | public function getPropertyValue($key) { |
| 64 | 64 | $methodName = 'get' . $this->getMethodName($key); |
| 65 | - if(method_exists($this, $methodName)) { |
|
| 65 | + if (method_exists($this, $methodName)) { |
|
| 66 | 66 | return $this->{$methodName}(); |
| 67 | 67 | } |
| 68 | 68 | return false; |
@@ -60,7 +60,8 @@ |
||
| 60 | 60 | * @param $key |
| 61 | 61 | * @return mixed |
| 62 | 62 | */ |
| 63 | - public function getPropertyValue($key) { |
|
| 63 | + public function getPropertyValue($key) |
|
| 64 | + { |
|
| 64 | 65 | $methodName = 'get' . $this->getMethodName($key); |
| 65 | 66 | if(method_exists($this, $methodName)) { |
| 66 | 67 | return $this->{$methodName}(); |
@@ -121,9 +121,7 @@ |
||
| 121 | 121 | { |
| 122 | 122 | $propertyName = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))); |
| 123 | 123 | |
| 124 | - return (property_exists($this, $propertyName)) ? $propertyName : |
|
| 125 | - (property_exists($this, lcfirst($propertyName)) ? lcfirst($propertyName) : |
|
| 126 | - preg_replace_callback('/([A-Z])/', function($match) { |
|
| 124 | + return (property_exists($this, $propertyName)) ? $propertyName : (property_exists($this, lcfirst($propertyName)) ? lcfirst($propertyName) : preg_replace_callback('/([A-Z])/', function ($match) { |
|
| 127 | 125 | return strtolower('_' . $match[1]); |
| 128 | 126 | }, lcfirst($propertyName)) |
| 129 | 127 | ); |
@@ -69,7 +69,8 @@ discard block |
||
| 69 | 69 | // Convert key to a propertyname in $this |
| 70 | 70 | try { |
| 71 | 71 | $this->hydrateProperty($itemKey, $itemValue, $reflection); |
| 72 | - } catch (\Exception $e) { |
|
| 72 | + } |
|
| 73 | + catch (\Exception $e) { |
|
| 73 | 74 | if ($failOnError) { |
| 74 | 75 | throw $e; |
| 75 | 76 | } |
@@ -113,7 +114,8 @@ discard block |
||
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | $this->setPropertyValue($propertyName, $value, true); |
| 116 | - } catch (\Exception $e) { |
|
| 117 | + } |
|
| 118 | + catch (\Exception $e) { |
|
| 117 | 119 | throw $e; |
| 118 | 120 | } |
| 119 | 121 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param object|array $class class |
| 55 | 55 | * @param boolean $failOnError Throw Exception if any error(s) occur |
| 56 | 56 | * |
| 57 | - * @return object |
|
| 57 | + * @return HydratableTrait |
|
| 58 | 58 | * |
| 59 | 59 | * @throws \Exception if hydration failes AND $failOnError is true |
| 60 | 60 | */ |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param $key |
| 123 | 123 | * |
| 124 | - * @return mixed|string |
|
| 124 | + * @return string |
|
| 125 | 125 | */ |
| 126 | 126 | private function resolvePropertyName($key) |
| 127 | 127 | { |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function getClassFromClassProperty($class, $property) |
| 22 | 22 | { |
| 23 | - if(!class_exists($class)) { |
|
| 24 | - throw new \Exception($class. ' not found or does not exist'); |
|
| 23 | + if (!class_exists($class)) { |
|
| 24 | + throw new \Exception($class . ' not found or does not exist'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if(!property_exists($class, $property)) { |
|
| 27 | + if (!property_exists($class, $property)) { |
|
| 28 | 28 | throw new \Exception($class . ' has no property with the name ' . $property); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | if (preg_match('~\@var[\s]+([A-Za-z0-9\\\\]+)~', $comment, $matches)) { |
| 44 | 44 | if ($includeNamespaces) { |
| 45 | 45 | if ($reflectionClass instanceof \ReflectionClass && !in_array($matches[1], HydratableTrait::$nonObjectTypes)) { |
| 46 | - return ($reflectionClass->getNamespaceName()) ? sprintf('\%s\%s', $reflectionClass->getNamespaceName(), $matches[1]) : sprintf('\%s', $matches[1]); |
|
| 46 | + return ($reflectionClass->getNamespaceName()) ? sprintf('\%s\%s', $reflectionClass->getNamespaceName(), $matches[1]) : sprintf('\%s', $matches[1]); |
|
| 47 | 47 | } |
| 48 | 48 | return $matches[1]; |
| 49 | 49 | } |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | public function recusiveImplode(array $array, $glue = ',') |
| 16 | 16 | { |
| 17 | - foreach($array as $key => $element) { |
|
| 18 | - if(is_array($element)) { |
|
| 17 | + foreach ($array as $key => $element) { |
|
| 18 | + if (is_array($element)) { |
|
| 19 | 19 | $array[$key] = $this->recusiveImplode($element, $glue); |
| 20 | 20 | } |
| 21 | 21 | } |