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

aplus-framework / config / 9816531644

28 Jun 2024 10:04PM UTC coverage: 100.0%. Remained the same
9816531644

push

github

natanfelles
Merge branch 'refs/heads/4.x' into development

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/Extra/JsonXMLElement.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\Extra;
11

12
/**
13
 * Class JsonXMLElement.
14
 *
15
 * @see \Framework\Config\Parsers\XmlParser
16
 *
17
 * @package config
18
 */
19
class JsonXMLElement extends \SimpleXMLElement implements \JsonSerializable
20
{
21
    /**
22
     * @return array<mixed>|string
23
     */
24
    public function jsonSerialize() : array | string
25
    {
26
        $data = [];
1✔
27
        foreach ($this as $name => $element) {
1✔
28
            $name = (string) $name;
1✔
29
            if (!isset($data[$name])) {
1✔
30
                $data[$name] = $element;
1✔
31
                continue;
1✔
32
            }
33
            if (!\is_array($data[$name])) {
1✔
34
                $data[$name] = [$data[$name]];
1✔
35
            }
36
            $data[$name][] = $element;
1✔
37
        }
38
        $text = \trim((string) $this);
1✔
39
        if (($text !== '') && empty($data)) {
1✔
40
            $data = $text;
1✔
41
        }
42
        return $data;
1✔
43
    }
44
}
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