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

nette / neon / 19670742063

25 Nov 2025 01:13PM UTC coverage: 98.485% (+0.02%) from 98.468%
19670742063

push

github

dg
used attribute Deprecated

455 of 462 relevant lines covered (98.48%)

0.98 hits per line

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

93.33
/src/Neon/Node/ArrayItemNode.php
1
<?php
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Nette\Neon\Node;
11

12
use Nette\Neon\Node;
13
use function substr;
14

15

16
/** @internal */
17
final class ArrayItemNode extends Node
18
{
19
        public ?Node $key = null;
20
        public Node $value;
21

22

23
        /**
24
         * @param  self[]  $items
25
         * @return mixed[]
26
         */
27
        public static function itemsToArray(array $items): array
1✔
28
        {
29
                $res = [];
1✔
30
                foreach ($items as $item) {
1✔
31
                        if ($item->key === null) {
1✔
32
                                $res[] = $item->value->toValue();
1✔
33
                        } else {
34
                                $res[(string) $item->key->toValue()] = $item->value->toValue();
1✔
35
                        }
36
                }
37

38
                return $res;
1✔
39
        }
40

41

42
        /** @param  self[]  $items */
43
        public static function itemsToInlineString(array $items): string
1✔
44
        {
45
                $res = '';
1✔
46
                foreach ($items as $item) {
1✔
47
                        $res .= ($res === '' ? '' : ', ')
1✔
48
                                . ($item->key ? $item->key->toString() . ': ' : '')
1✔
49
                                . $item->value->toString();
1✔
50
                }
51

52
                return $res;
1✔
53
        }
54

55

56
        /** @param  self[]  $items */
57
        public static function itemsToBlockString(array $items): string
1✔
58
        {
59
                $res = '';
1✔
60
                foreach ($items as $item) {
1✔
61
                        $v = $item->value->toString();
1✔
62
                        $res .= ($item->key ? $item->key->toString() . ':' : '-')
1✔
63
                                . ($item->value instanceof BlockArrayNode && $item->value->items
1✔
64
                                        ? "\n" . $v . (substr($v, -2, 1) === "\n" ? '' : "\n")
1✔
65
                                        : ' ' . $v . "\n");
1✔
66
                }
67

68
                return $res;
1✔
69
        }
70

71

72
        public function toValue(): mixed
73
        {
74
                throw new \LogicException;
×
75
        }
76

77

78
        public function toString(): string
79
        {
80
                throw new \LogicException;
×
81
        }
82

83

84
        public function &getIterator(): \Generator
1✔
85
        {
86
                if ($this->key) {
1✔
87
                        yield $this->key;
1✔
88
                }
89
                yield $this->value;
1✔
90
        }
1✔
91
}
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

© 2026 Coveralls, Inc