Skip to content

Commit

Permalink
Merge 1b32a72 into dc4053b
Browse files Browse the repository at this point in the history
  • Loading branch information
vanodevium committed Mar 11, 2020
2 parents dc4053b + 1b32a72 commit 58d0c60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=5.5",
"php": ">=5.6",
"ext-json": "*"
},
"require-dev": {
Expand Down
27 changes: 12 additions & 15 deletions src/Dot.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function add($keys, $value = null)
foreach ($keys as $key => $value) {
$this->add($key, $value);
}
} elseif (is_null($this->get($keys))) {
} elseif ($this->get($keys) === null) {
$this->set($keys, $value);
}
}
Expand All @@ -74,7 +74,7 @@ public function all()
*/
public function clear($keys = null)
{
if (is_null($keys)) {
if ($keys === null) {
$this->items = [];

return;
Expand Down Expand Up @@ -144,22 +144,19 @@ public function flatten($delimiter = '.', $items = null, $prepend = '')
{
$flatten = [];

if (is_null($items)) {
if ($items === null) {
$items = $this->items;
}

foreach ($items as $key => $value) {
if (is_array($value) && !empty($value)) {
$flatten = array_merge(
$flatten,
$this->flatten($delimiter, $value, $prepend.$key.$delimiter)
);
$flatten[] = $this->flatten($delimiter, $value, $prepend.$key.$delimiter);
} else {
$flatten[$prepend.$key] = $value;
$flatten[] = [$prepend.$key => $value];
}
}

return $flatten;
return array_merge(...$flatten);
}

/**
Expand All @@ -171,7 +168,7 @@ public function flatten($delimiter = '.', $items = null, $prepend = '')
*/
public function get($key = null, $default = null)
{
if (is_null($key)) {
if ($key === null) {
return $this->items;
}

Expand Down Expand Up @@ -254,7 +251,7 @@ public function has($keys)
*/
public function isEmpty($keys = null)
{
if (is_null($keys)) {
if ($keys === null) {
return empty($this->items);
}

Expand Down Expand Up @@ -371,7 +368,7 @@ protected function arrayMergeRecursiveDistinct(array $array1, array $array2)
*/
public function pull($key = null, $default = null)
{
if (is_null($key)) {
if ($key === null) {
$value = $this->all();
$this->clear();

Expand All @@ -393,15 +390,15 @@ public function pull($key = null, $default = null)
*/
public function push($key, $value = null)
{
if (is_null($value)) {
if ($value === null) {
$this->items[] = $key;

return;
}

$items = $this->get($key);

if (is_array($items) || is_null($items)) {
if (is_array($items) || $items === null) {
$items[] = $value;
$this->set($key, $items);
}
Expand Down Expand Up @@ -531,7 +528,7 @@ public function offsetGet($key)
*/
public function offsetSet($key, $value)
{
if (is_null($key)) {
if ($key === null) {
$this->items[] = $value;

return;
Expand Down

0 comments on commit 58d0c60

Please sign in to comment.