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

JBZoo / Data / 7796885268

28 Jan 2024 08:47AM UTC coverage: 98.958%. Remained the same
7796885268

push

github

web-flow
Add PHP 8.3 support and update dependencies in composer.json (#31)

190 of 192 relevant lines covered (98.96%)

38.97 hits per line

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

100.0
/src/Ini.php
1
<?php
2

3
/**
4
 * JBZoo Toolbox - Data.
5
 *
6
 * This file is part of the JBZoo Toolbox project.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT
11
 * @copyright  Copyright (C) JBZoo.com, All rights reserved.
12
 * @see        https://github.com/JBZoo/Data
13
 */
14

15
declare(strict_types=1);
16

17
namespace JBZoo\Data;
18

19
final class Ini extends AbstractData
20
{
21
    protected function decode(string $string): mixed
22
    {
23
        return \parse_ini_string($string, true, \INI_SCANNER_NORMAL);
24✔
24
    }
25

26
    protected function encode(array $data): string
27
    {
28
        return $this->render($data);
18✔
29
    }
30

31
    protected function render(array $data = [], array $parent = []): string
32
    {
33
        $result = [];
18✔
34

35
        foreach ($data as $dataKey => $dataValue) {
18✔
36
            if (\is_array($dataValue)) {
18✔
37
                if (self::isMulti($dataValue)) {
12✔
38
                    $sections = \array_merge($parent, (array)$dataKey);
12✔
39
                    $result[] = '';
12✔
40
                    $result[] = '[' . \implode('.', $sections) . ']';
12✔
41
                    $result[] = $this->render($dataValue, $sections);
12✔
42
                } else {
43
                    foreach ($dataValue as $key => $value) {
12✔
44
                        $result[] = $dataKey . '[' . $key . '] = "' . \str_replace('"', '\"', (string)$value) . '"';
12✔
45
                    }
46
                }
47
            } else {
48
                $result[] = $dataKey . ' = "' . \str_replace('"', '\"', (string)$dataValue) . '"';
18✔
49
            }
50
        }
51

52
        return \implode(Data::LE, $result);
18✔
53
    }
54
}
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