Skip to content

Commit

Permalink
Merge pull request #3 from PabloGancharov/master
Browse files Browse the repository at this point in the history
Added Exception handling: InvalidArgumentException
  • Loading branch information
amitdar committed Dec 19, 2014
2 parents 791772e + 91e49ca commit 299b4b4
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions zray.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,28 @@ private function collectConfig($config, &$storage) {
*
* @return array
*/
private function makeArraySerializable($data)
{
$serializable = array();

foreach (ArrayUtils::iteratorToArray($data) as $key => $value) {
if ($value instanceof Traversable || is_array($value)) {
$serializable[$key] = $this->makeArraySerializable($value);

continue;
}

if ($value instanceof Closure) {
$serializable[$key] = new ClosureStub();

continue;
}

$serializable[$key] = $value;
}

return $serializable;
private function makeArraySerializable($data) {
$serializable = array();
try {
foreach (ArrayUtils::iteratorToArray($data) as $key => $value) {
if ($value instanceof Traversable || is_array($value)) {
$serializable[$key] = $this->makeArraySerializable($value);

continue;
}

if ($value instanceof Closure) {
$serializable[$key] = new ClosureStub();
continue;
}

$serializable[$key] = $value;
}
} catch (\InvalidArgumentException $e) {
return $serializable;
}

return $serializable;
}

private function reorderArray($config) {
Expand Down

0 comments on commit 299b4b4

Please sign in to comment.