Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit be15496

Browse files
author
Andrey Helldar
committed
Boolean processing error fixed
1 parent 9c21c5f commit be15496

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/DataTransferObject.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ protected function setItems(array $items): void
7474

7575
protected function getValueByKey(array $items, string $key, string $default)
7676
{
77-
return Arr::get($items, $key) ?: Arr::get($items, $default);
77+
if (Arr::exists($items, $key)) {
78+
return Arr::get($items, $key);
79+
}
80+
81+
return Arr::get($items, $default);
7882
}
7983

8084
/**

tests/Unit/MapTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,23 @@ public function testToArray()
5858
'baz' => $this->baz,
5959
], $object->toArray());
6060
}
61+
62+
public function testMissingValues()
63+
{
64+
$object = new Map([
65+
'wa' => [
66+
'sd' => $this->foo,
67+
],
68+
69+
'qwe.rty' => false,
70+
]);
71+
72+
$this->assertIsArray($object->toArray());
73+
74+
$this->assertSame([
75+
'foo' => $this->foo,
76+
'bar' => false,
77+
'baz' => null,
78+
], $object->toArray());
79+
}
6180
}

0 commit comments

Comments
 (0)