Skip to content

Commit

Permalink
Fail message differ if is not array or more than on depth
Browse files Browse the repository at this point in the history
  • Loading branch information
stephpy committed Jul 4, 2012
1 parent 961571e commit 6c646c8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Request/ParamFetcher.php
Expand Up @@ -93,9 +93,17 @@ public function get($name, $strict = null)
}

if ($config->array) {
if (!is_array($param) || count($param) !== count($param, COUNT_RECURSIVE)) {
$failMessage = null;

if (!is_array($param)) {
$failMessage = sprintf("Query parameter value '%s' is not an array", $param);
} elseif(count($param) !== count($param, COUNT_RECURSIVE)) {
$failMessage = sprintf("Query parameter value '%s' must not have more than one depth", $param);
}

if (null !== $failMessage) {
if ($strict) {
throw new \RuntimeException(sprintf("Query parameter value '%s' is not an array", $param));
throw new \RuntimeException($failMessage);
}

return array($default);
Expand Down

0 comments on commit 6c646c8

Please sign in to comment.