Skip to content

Commit

Permalink
Resolving ambiguities in dump function code
Browse files Browse the repository at this point in the history
  • Loading branch information
DusanKasan committed Jun 8, 2016
1 parent e24d0d6 commit ff594da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"src/utility_functions.php"
],
"psr-4": {
"DusanKasan\\Knapsack\\": "src/",
"DusanKasan\\Knapsack\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DusanKasan\\Knapsack\\Tests\\Helpers\\": "tests/helpers/"
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/collection_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1661,14 +1661,14 @@ function dump($input, $maxItemsPerCollection = null, $maxDepth = null)
return $input;
}

if (isCollection($input)) {
if (is_array($input) || $input instanceof Traversable) {
if ($maxDepth === 0) {
return '^^^';
}

$normalizedProperties = [];
foreach ($input as $key => $value) {
if ($maxItemsPerCollection && count($normalizedProperties) >= $maxItemsPerCollection) {
if ($maxItemsPerCollection !== null && count($normalizedProperties) >= $maxItemsPerCollection) {
$normalizedProperties[] = '>>>';
break;
}
Expand Down
1 change: 0 additions & 1 deletion tests/helpers/Car.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace DusanKasan\Knapsack\Tests\Helpers;


class Car extends Machine
{
/**
Expand Down
1 change: 0 additions & 1 deletion tests/helpers/Machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace DusanKasan\Knapsack\Tests\Helpers;


class Machine
{
/**
Expand Down

0 comments on commit ff594da

Please sign in to comment.