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

MyIntervals / PHP-CSS-Parser / 13888197372

16 Mar 2025 10:54PM UTC coverage: 55.929%. Remained the same
13888197372

Pull #818

github

web-flow
Merge b7b0433d9 into f9609c497
Pull Request #818: [TASK] Use native types for all constructor parameters

3 of 6 new or added lines in 6 files covered. (50.0%)

1047 of 1872 relevant lines covered (55.93%)

12.64 hits per line

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

0.0
/src/Value/CSSFunction.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\Parsing\ParserState;
9
use Sabberworm\CSS\Parsing\SourceException;
10
use Sabberworm\CSS\Parsing\UnexpectedEOFException;
11
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
12

13
/**
14
 * A `CSSFunction` represents a special kind of value that also contains a function name and where the values are the
15
 * function’s arguments. It also handles equals-sign-separated argument lists like `filter: alpha(opacity=90);`.
16
 */
17
class CSSFunction extends ValueList
18
{
19
    /**
20
     * @var string
21
     *
22
     * @internal since 8.8.0
23
     */
24
    protected $name;
25

26
    /**
27
     * @param RuleValueList|array<array-key, Value|string> $arguments
28
     * @param int<0, max> $lineNumber
29
     */
NEW
30
    public function __construct(string $name, $arguments, string $separator = ',', int $lineNumber = 0)
×
31
    {
32
        if ($arguments instanceof RuleValueList) {
×
33
            $separator = $arguments->getListSeparator();
×
34
            $arguments = $arguments->getListComponents();
×
35
        }
36
        $this->name = $name;
×
37
        $this->lineNumber = $lineNumber;
×
38
        parent::__construct($arguments, $separator, $lineNumber);
×
39
    }
×
40

41
    /**
42
     * @throws SourceException
43
     * @throws UnexpectedEOFException
44
     * @throws UnexpectedTokenException
45
     *
46
     * @internal since V8.8.0
47
     */
48
    public static function parse(ParserState $parserState, bool $ignoreCase = false): CSSFunction
×
49
    {
50
        $name = self::parseName($parserState, $ignoreCase);
×
51
        $parserState->consume('(');
×
52
        $arguments = self::parseArguments($parserState);
×
53

54
        $result = new CSSFunction($name, $arguments, ',', $parserState->currentLine());
×
55
        $parserState->consume(')');
×
56

57
        return $result;
×
58
    }
59

60
    /**
61
     * @throws SourceException
62
     * @throws UnexpectedEOFException
63
     * @throws UnexpectedTokenException
64
     */
65
    private static function parseName(ParserState $parserState, bool $ignoreCase = false): string
×
66
    {
67
        return $parserState->parseIdentifier($ignoreCase);
×
68
    }
69

70
    /**
71
     * @return Value|string
72
     *
73
     * @throws SourceException
74
     * @throws UnexpectedEOFException
75
     * @throws UnexpectedTokenException
76
     */
77
    private static function parseArguments(ParserState $parserState)
×
78
    {
79
        return Value::parseValue($parserState, ['=', ' ', ',']);
×
80
    }
81

82
    /**
83
     * @return string
84
     */
85
    public function getName()
×
86
    {
87
        return $this->name;
×
88
    }
89

90
    /**
91
     * @param string $name
92
     */
93
    public function setName($name): void
×
94
    {
95
        $this->name = $name;
×
96
    }
×
97

98
    /**
99
     * @return array<array-key, Value|string>
100
     */
101
    public function getArguments()
×
102
    {
103
        return $this->components;
×
104
    }
105

106
    /**
107
     * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
108
     */
109
    public function __toString(): string
×
110
    {
111
        return $this->render(new OutputFormat());
×
112
    }
113

114
    public function render(OutputFormat $outputFormat): string
×
115
    {
116
        $arguments = parent::render($outputFormat);
×
117
        return "{$this->name}({$arguments})";
×
118
    }
119
}
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