Skip to content

Commit

Permalink
Cover it all
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro committed Nov 30, 2017
1 parent bd8f490 commit f1fb400
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
1 change: 1 addition & 0 deletions phpunit.xml
Expand Up @@ -20,6 +20,7 @@
<logging>
<log type="coverage-html" target="coverage/" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="coverage/coverage-clover.xml" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
Expand Down
28 changes: 3 additions & 25 deletions src/package/Yaml.php
Expand Up @@ -2,13 +2,9 @@

namespace PragmaRX\Yaml\Package;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Collection;
use JsonSerializable;
use PragmaRX\Yaml\Package\Support\File;
use PragmaRX\Yaml\Package\Support\Parser;
use Traversable;

class Yaml
{
Expand Down Expand Up @@ -86,7 +82,7 @@ public function recursivelyFindAndReplaceKeysToSelf($new, $keys = null)
do {
$old = $new;

if (is_array($old instanceof Arrayable ? $old->toArray() : $old)) {
if (is_array($old instanceof Collection ? $old->toArray() : $old)) {
return collect($old)->map(function ($item) use ($keys) {
return $this->recursivelyFindAndReplaceKeysToSelf($item, $keys);
});
Expand Down Expand Up @@ -126,7 +122,7 @@ public function replaceKeysToSelf($string, $keys)
*/
protected function recursivelyFindAndReplaceExecutableCode($old)
{
if (is_array($old instanceof Arrayable ? $old->toArray() : $old)) {
if (is_array($old instanceof Collection ? $old->toArray() : $old)) {
return collect($old)->map(function ($item) {
return $this->recursivelyFindAndReplaceExecutableCode($item);
});
Expand Down Expand Up @@ -235,7 +231,7 @@ public function loadFile($file, $parseYaml = true)
*/
public function cleanArrayKeysRecursive($dirty)
{
if (is_array($dirty instanceof Arrayable ? $dirty->toArray() : $dirty)) {
if (is_array($dirty instanceof Collection ? $dirty->toArray() : $dirty)) {
return collect($dirty)->mapWithKeys(function ($item, $key) {
return [
$this->cleanKey($key) => $this->cleanArrayKeysRecursive($item),
Expand Down Expand Up @@ -269,22 +265,4 @@ public function instance()
{
return $this;
}

/**
* Check if value is arrayable.
*
* @param mixed $items
*
* @return bool
*/
protected function isArrayable($items)
{
return
is_array($items) ||
$items instanceof self ||
$items instanceof Arrayable ||
$items instanceof Jsonable ||
$items instanceof JsonSerializable ||
$items instanceof Traversable;
}
}

0 comments on commit f1fb400

Please sign in to comment.