• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aplus-framework / config / 7243496232

06 Dec 2023 08:09PM UTC coverage: 100.0%. Remained the same
7243496232

push

github

natanfelles
Test with PHP latest version

206 of 206 relevant lines covered (100.0%)

2.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Parsers/IniParser.php
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of Aplus Framework Config Library.
4
 *
5
 * (c) Natan Felles <natanfelles@gmail.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Framework\Config\Parsers;
11

12
/**
13
 * Class IniParser.
14
 *
15
 * @package config
16
 */
17
class IniParser extends Parser
18
{
19
    /**
20
     * Parses an INI file.
21
     *
22
     * @param mixed $config path to the INI file
23
     *
24
     * @throws ParserException
25
     *
26
     * @return array<mixed> The INI parsed data
27
     */
28
    public static function parse(mixed $config) : array
29
    {
30
        static::checkConfig($config);
2✔
31
        return static::parseOrThrow(static function () use ($config) : array {
2✔
32
            $parsed = \parse_ini_file($config, true, \INI_SCANNER_TYPED);
2✔
33
            $data = [];
1✔
34
            // @phpstan-ignore-next-line
35
            foreach ($parsed as $section => $values) {
1✔
36
                $data[$section] = [];
1✔
37
                foreach ($values as $key => $value) {
1✔
38
                    $key = \explode('.', $key);
1✔
39
                    $parent = [];
1✔
40
                    static::addChild($parent, $key, $value);
1✔
41
                    $data[$section] = \array_replace_recursive(
1✔
42
                        $data[$section],
1✔
43
                        $parent
1✔
44
                    );
1✔
45
                }
46
            }
47
            return static::ksortRecursive($data);
1✔
48
        });
2✔
49
    }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc