Skip to content

Commit

Permalink
Fix when input data is not an object or array
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo St-Onge committed Dec 6, 2017
1 parent 9536b09 commit 64b051a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Folklore/EloquentJsonSchema/Support/JsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public function getNodes($root = null)
$properties = $items;
}
}
// @TODO Handle other types

$nodes = new NodesCollection();
foreach ($properties as $name => $propertySchema) {
Expand Down Expand Up @@ -283,7 +284,7 @@ public function getNodesFromData($data, $root = null)
{
$nodes = $this->getNodes($root);
$dataArray = !is_null($data) ? json_decode(json_encode($data), true) : [];
$dataPaths = array_keys(array_dot($dataArray));
$dataPaths = is_array($dataArray) ? array_keys(array_dot($dataArray)) : [];
return $nodes->reduce(function ($collection, $node) use ($dataPaths, $data) {
$paths = $this->getMatchingPaths($dataPaths, $node->path);
foreach ($paths as $path) {
Expand Down

0 comments on commit 64b051a

Please sign in to comment.