diff --git a/src/Dot.php b/src/Dot.php index f3436af..b539412 100644 --- a/src/Dot.php +++ b/src/Dot.php @@ -38,9 +38,9 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable public function __construct($items = [], $parse = false) { $items = $this->getArrayItems($items); - if ($parse === true) { - $this->set($items); - return; + + if ($parse) { + return $this->set($items); } $this->items = $items; diff --git a/tests/DotTest.php b/tests/DotTest.php index c8e136e..fdd6a5d 100644 --- a/tests/DotTest.php +++ b/tests/DotTest.php @@ -59,8 +59,11 @@ public function testConstructHelper() public function testConstructWithParsing() { $dot = new Dot(['foo.bar' => 'baz']); + $this->assertEquals(['foo.bar' => 'baz'], $dot->get()); + $dot = new Dot(['foo.bar' => 'baz'], true); + $this->assertEquals(['foo' => ['bar' => 'baz']], $dot->get()); }