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

MyIntervals / PHP-CSS-Parser / 11785175003

11 Nov 2024 07:46PM UTC coverage: 38.583% (-0.04%) from 38.622%
11785175003

push

github

web-flow
[TASK] Clean up the code with Rector (#772)

Just the Rector changes, and some redundancy removal related to
those, but nothing more.

10 of 19 new or added lines in 9 files covered. (52.63%)

1 existing line in 1 file now uncovered.

779 of 2019 relevant lines covered (38.58%)

5.33 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

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

21
    /**
22
     * @param string $sName
23
     * @param RuleValueList|array<int, Value|string> $aArguments
24
     * @param string $sSeparator
25
     * @param int $iLineNo
26
     */
27
    public function __construct($sName, $aArguments, $sSeparator = ',', $iLineNo = 0)
×
28
    {
29
        if ($aArguments instanceof RuleValueList) {
×
30
            $sSeparator = $aArguments->getListSeparator();
×
31
            $aArguments = $aArguments->getListComponents();
×
32
        }
33
        $this->sName = $sName;
×
34
        $this->iLineNo = $iLineNo;
×
35
        parent::__construct($aArguments, $sSeparator, $iLineNo);
×
36
    }
×
37

38
    /**
39
     * @throws SourceException
40
     * @throws UnexpectedEOFException
41
     * @throws UnexpectedTokenException
42
     */
43
    public static function parse(ParserState $oParserState, bool $bIgnoreCase = false): CSSFunction
×
44
    {
45
        $sName = self::parseName($oParserState, $bIgnoreCase);
×
46
        $oParserState->consume('(');
×
47
        $mArguments = self::parseArguments($oParserState);
×
48

49
        $oResult = new CSSFunction($sName, $mArguments, ',', $oParserState->currentLine());
×
50
        $oParserState->consume(')');
×
51

52
        return $oResult;
×
53
    }
54

55
    /**
56
     * @throws SourceException
57
     * @throws UnexpectedEOFException
58
     * @throws UnexpectedTokenException
59
     */
60
    private static function parseName(ParserState $oParserState, bool $bIgnoreCase = false): string
×
61
    {
62
        return $oParserState->parseIdentifier($bIgnoreCase);
×
63
    }
64

65
    /**
66
     * @return Value|string
67
     *
68
     * @throws SourceException
69
     * @throws UnexpectedEOFException
70
     * @throws UnexpectedTokenException
71
     */
72
    private static function parseArguments(ParserState $oParserState)
×
73
    {
74
        return Value::parseValue($oParserState, ['=', ' ', ',']);
×
75
    }
76

77
    /**
78
     * @return string
79
     */
80
    public function getName()
×
81
    {
82
        return $this->sName;
×
83
    }
84

85
    /**
86
     * @param string $sName
87
     */
88
    public function setName($sName): void
×
89
    {
90
        $this->sName = $sName;
×
91
    }
×
92

93
    /**
94
     * @return array<int, Value|string>
95
     */
96
    public function getArguments()
×
97
    {
98
        return $this->aComponents;
×
99
    }
100

101
    public function __toString(): string
×
102
    {
103
        return $this->render(new OutputFormat());
×
104
    }
105

NEW
106
    public function render(OutputFormat $oOutputFormat): string
×
107
    {
108
        $aArguments = parent::render($oOutputFormat);
×
109
        return "{$this->sName}({$aArguments})";
×
110
    }
111
}
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