Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Reader/Ini.php
Expand Up @@ -130,7 +130,12 @@ protected function process(array $data)

foreach ($data as $section => $value) {
if (is_array($value)) {
$config[$section] = $this->processSection($value);
if (strpos($section, $this->nestSeparator) !== false) {
$section = explode($this->nestSeparator, $section, 2);
$config[$section[0]][$section[1]] = $this->processSection($value);
} else {
$config[$section] = $this->processSection($value);
}
} else {
$this->processKey($section, $value, $config);
}
Expand Down
17 changes: 17 additions & 0 deletions test/Reader/IniTest.php
Expand Up @@ -83,4 +83,21 @@ public function testFromStringWithSection()
$this->assertEquals($arrayIni['all']['bar'][0], 'baz');
$this->assertEquals($arrayIni['all']['bar'][1], 'foo');
}

public function testFromStringNested()
{
$ini = <<<ECS
foo.bar = foobar
foobar[] = foobarArray
foo.baz[] = foobaz1
foo.baz[] = foobaz2
ECS;

$arrayIni = $this->reader->fromString($ini);
$this->assertEquals($arrayIni['foo']['bar'], 'foobar');
$this->assertEquals($arrayIni['foobar'][0], 'foobarArray');
$this->assertEquals($arrayIni['foo']['baz'][0], 'foobaz1');
$this->assertEquals($arrayIni['foo']['baz'][1], 'foobaz2');
}
}

0 comments on commit 98ac67f

Please sign in to comment.