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

MyIntervals / PHP-CSS-Parser / 13699188625

06 Mar 2025 12:55PM UTC coverage: 55.655%. Remained the same
13699188625

push

github

web-flow
[CLEANUP] Avoid Hungarian notation for `url` (#1093)

Part of #756

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

1053 of 1892 relevant lines covered (55.66%)

12.21 hits per line

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

78.13
/src/Value/URL.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
 * This class represents URLs in CSS. `URL`s always output in `URL("")` notation.
15
 */
16
class URL extends PrimitiveValue
17
{
18
    /**
19
     * @var CSSString
20
     */
21
    private $url;
22

23
    /**
24
     * @param int<0, max> $lineNumber
25
     */
26
    public function __construct(CSSString $url, $lineNumber = 0)
14✔
27
    {
28
        parent::__construct($lineNumber);
14✔
29
        $this->url = $url;
14✔
30
    }
14✔
31

32
    /**
33
     * @throws SourceException
34
     * @throws UnexpectedEOFException
35
     * @throws UnexpectedTokenException
36
     *
37
     * @internal since V8.8.0
38
     */
39
    public static function parse(ParserState $parserState): URL
14✔
40
    {
41
        $anchor = $parserState->anchor();
14✔
42
        $identifier = '';
14✔
43
        for ($i = 0; $i < 3; $i++) {
14✔
44
            $sChar = $parserState->parseCharacter(true);
14✔
45
            if ($sChar === null) {
14✔
46
                break;
4✔
47
            }
48
            $identifier .= $sChar;
11✔
49
        }
50
        $bUseUrl = $parserState->streql($identifier, 'url');
14✔
51
        if ($bUseUrl) {
14✔
52
            $parserState->consumeWhiteSpace();
11✔
53
            $parserState->consume('(');
11✔
54
        } else {
55
            $anchor->backtrack();
4✔
56
        }
57
        $parserState->consumeWhiteSpace();
14✔
58
        $result = new URL(CSSString::parse($parserState), $parserState->currentLine());
14✔
59
        if ($bUseUrl) {
14✔
60
            $parserState->consumeWhiteSpace();
11✔
61
            $parserState->consume(')');
11✔
62
        }
63
        return $result;
14✔
64
    }
65

NEW
66
    public function setURL(CSSString $url): void
×
67
    {
NEW
68
        $this->url = $url;
×
69
    }
×
70

71
    /**
72
     * @return CSSString
73
     */
74
    public function getURL()
×
75
    {
NEW
76
        return $this->url;
×
77
    }
78

79
    /**
80
     * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
81
     */
82
    public function __toString(): string
×
83
    {
84
        return $this->render(new OutputFormat());
×
85
    }
86

87
    public function render(OutputFormat $outputFormat): string
10✔
88
    {
89
        return "url({$this->url->render($outputFormat)})";
10✔
90
    }
91
}
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