Skip to content

Commit

Permalink
Depth param is as of PHP 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Mar 2, 2016
1 parent 55b81a8 commit 54fcb51
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Format/Json.php
Expand Up @@ -31,9 +31,16 @@ class Json extends AbstractRegistryFormat
public function objectToString($object, $options = array())
{
$bitmask = isset($options['bitmask']) ? $options['bitmask'] : 0;
$depth = isset($options['depth']) ? $options['depth'] : 512;

return StringHelper::unicode_to_utf8(json_encode($object, $bitmask, $depth));
// The depth parameter is only present as of PHP 5.5
if (version_compare(PHP_VERSION, '5.5', '>='))
{
$depth = isset($options['depth']) ? $options['depth'] : 512;

return StringHelper::unicode_to_utf8(json_encode($object, $bitmask, $depth));
}

return StringHelper::unicode_to_utf8(json_encode($object, $bitmask));
}

/**
Expand Down

0 comments on commit 54fcb51

Please sign in to comment.