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

MyIntervals / PHP-CSS-Parser / 13716838860

07 Mar 2025 08:35AM UTC coverage: 55.626%. Remained the same
13716838860

Pull #1105

github

web-flow
Merge 26aa3cb2a into 4f45adbf3
Pull Request #1105: [CLEANUP] Avoid Hungarian notation in `DeclarationBlock`

4 of 4 new or added lines in 1 file covered. (100.0%)

1053 of 1893 relevant lines covered (55.63%)

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

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

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

59
        return $result;
×
60
    }
61

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

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

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

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

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

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

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