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

nette / neon / 19670393644

18 Jun 2025 07:35PM UTC coverage: 98.468% (-0.007%) from 98.475%
19670393644

push

github

dg
used attribute Deprecated

450 of 457 relevant lines covered (98.47%)

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

14

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

21

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

37
                return $res;
1✔
38
        }
39

40

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

51
                return $res;
1✔
52
        }
53

54

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

67
                return $res;
1✔
68
        }
69

70

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

76

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

82

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