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

MyIntervals / PHP-CSS-Parser / 20667833138

02 Jan 2026 10:19PM UTC coverage: 69.199% (-0.8%) from 70.0%
20667833138

Pull #1441

github

web-flow
Merge 331bdac72 into ecde963ce
Pull Request #1441: [TASK] Add `getArrayRepresentation` method for testing

2 of 12 new or added lines in 3 files covered. (16.67%)

9 existing lines in 2 files now uncovered.

1357 of 1961 relevant lines covered (69.2%)

32.59 hits per line

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

23.53
/src/Value/ValueList.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Sabberworm\CSS\Value;
6

7
use Sabberworm\CSS\OutputFormat;
8
use Sabberworm\CSS\ShortClassNameProvider;
9

10
/**
11
 * A `ValueList` represents a lists of `Value`s, separated by some separation character
12
 * (mostly `,`, whitespace, or `/`).
13
 *
14
 * There are two types of `ValueList`s: `RuleValueList` and `CSSFunction`
15
 */
16
abstract class ValueList extends Value
17
{
18
    use ShortClassNameProvider;
19

20
    /**
21
     * @var array<Value|string>
22
     *
23
     * @internal since 8.8.0
24
     */
25
    protected $components;
26

27
    /**
28
     * @var non-empty-string
29
     *
30
     * @internal since 8.8.0
31
     */
32
    protected $separator;
33

34
    /**
35
     * @param array<Value|string>|Value|string $components
36
     * @param non-empty-string $separator
37
     * @param int<1, max>|null $lineNumber
38
     */
39
    public function __construct($components = [], $separator = ',', ?int $lineNumber = null)
4✔
40
    {
41
        parent::__construct($lineNumber);
4✔
42
        if (!\is_array($components)) {
4✔
43
            $components = [$components];
×
44
        }
45
        $this->components = $components;
4✔
46
        $this->separator = $separator;
4✔
47
    }
4✔
48

49
    /**
50
     * @param Value|string $component
51
     */
52
    public function addListComponent($component): void
×
53
    {
54
        $this->components[] = $component;
×
55
    }
×
56

57
    /**
58
     * @return array<Value|string>
59
     */
60
    public function getListComponents(): array
×
61
    {
62
        return $this->components;
×
63
    }
64

65
    /**
66
     * @param array<Value|string> $components
67
     */
68
    public function setListComponents(array $components): void
×
69
    {
70
        $this->components = $components;
×
71
    }
×
72

73
    /**
74
     * @return non-empty-string
75
     */
76
    public function getListSeparator(): string
1✔
77
    {
78
        return $this->separator;
1✔
79
    }
80

81
    /**
82
     * @param non-empty-string $separator
83
     */
84
    public function setListSeparator(string $separator): void
×
85
    {
86
        $this->separator = $separator;
×
87
    }
×
88

89
    public function render(OutputFormat $outputFormat): string
×
90
    {
91
        $formatter = $outputFormat->getFormatter();
×
92

93
        return $formatter->implode(
×
94
            $formatter->spaceBeforeListArgumentSeparator($this->separator) . $this->separator
×
95
            . $formatter->spaceAfterListArgumentSeparator($this->separator),
×
96
            $this->components
×
97
        );
98
    }
99

100
    /**
101
     * @internal
102
     *
103
     * @return array<string, bool|int|float|string|list<array<string, mixed>>>
104
     */
NEW
105
    public function getArrayRepresentation(): array
×
106
    {
107
        return [
NEW
108
            'class' => $this->getShortClassName(),
×
NEW
109
            'components' => \array_map(
×
110
                /**
111
                 * @parm Value|string $component
112
                 *
113
                 * @return array|string
114
                 */
115
                function ($component) {
NEW
116
                    if (\is_string($component)) {
×
NEW
117
                        return $component;
×
118
                    }
NEW
119
                    return $component->getArrayRepresentation();
×
NEW
120
                },
×
NEW
121
                $this->components
×
122
            ),
123
        ];
124
    }
125
}
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