diff --git a/src/Hydrator.php b/src/Hydrator.php index c69d916..3004054 100755 --- a/src/Hydrator.php +++ b/src/Hydrator.php @@ -21,7 +21,7 @@ public static function hydrate(string $className, array $data = null): ?object return null; } - $data = Arr::mapKeys($data, function($key) { + $data = Arr::mapKeys($data, function ($key) { return Str::removeSpaces($key); }); @@ -29,7 +29,7 @@ public static function hydrate(string $className, array $data = null): ?object $publicProperties = $reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC); foreach ($publicProperties as $property) { - $value = array_key_exists($property->getName(),$data) + $value = array_key_exists($property->getName(), $data) ? $data[$property->getName()] : null; diff --git a/src/Support/Arr.php b/src/Support/Arr.php index aeba914..108b69b 100644 --- a/src/Support/Arr.php +++ b/src/Support/Arr.php @@ -36,7 +36,7 @@ public static function isList(array $array): bool */ public static function mapKeys(array $array, Closure $callback): array { - $newKeys = array_map( + $newKeys = array_map( $callback, array_keys($array), $array,