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

MyIntervals / PHP-CSS-Parser / 13270679659

11 Feb 2025 07:12PM UTC coverage: 49.156%. Remained the same
13270679659

Pull #910

github

web-flow
Merge c5f9fd700 into a5d22be77
Pull Request #910: [CLEANUP] Avoid Hungarian notation for `outputFormat`

22 of 58 new or added lines in 18 files covered. (37.93%)

1 existing line in 1 file now uncovered.

932 of 1896 relevant lines covered (49.16%)

11.42 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 $sName;
25

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

43
    /**
44
     * @throws SourceException
45
     * @throws UnexpectedEOFException
46
     * @throws UnexpectedTokenException
47
     */
48
    public static function parse(ParserState $parserState, bool $bIgnoreCase = false): CSSFunction
×
49
    {
50
        $sName = self::parseName($parserState, $bIgnoreCase);
×
51
        $parserState->consume('(');
×
52
        $mArguments = self::parseArguments($parserState);
×
53

54
        $result = new CSSFunction($sName, $mArguments, ',', $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 $bIgnoreCase = false): string
×
66
    {
67
        return $parserState->parseIdentifier($bIgnoreCase);
×
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->sName;
×
88
    }
89

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

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

106
    public function __toString(): string
×
107
    {
108
        return $this->render(new OutputFormat());
×
109
    }
110

NEW
111
    public function render(OutputFormat $outputFormat): string
×
112
    {
NEW
113
        $aArguments = parent::render($outputFormat);
×
114
        return "{$this->sName}({$aArguments})";
×
115
    }
116
}
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