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

MyIntervals / PHP-CSS-Parser / 13921221957

18 Mar 2025 10:41AM UTC coverage: 51.499% (-5.3%) from 56.839%
13921221957

push

github

web-flow
[TASK] Reduce and finetune the scope of `@covers` annotations (#1188)

The legacy tests are not very focused. Until we have split them
up, try to avoid false positives for code coverage.

Also add `@covers` annotations for the parent classes of the
tested classes.

945 of 1835 relevant lines covered (51.5%)

6.71 hits per line

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

30.0
/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, int $lineNumber = 0)
6✔
27
    {
28
        parent::__construct($lineNumber);
6✔
29
        $this->url = $url;
6✔
30
    }
6✔
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
×
40
    {
41
        $anchor = $parserState->anchor();
×
42
        $identifier = '';
×
43
        for ($i = 0; $i < 3; $i++) {
×
44
            $character = $parserState->parseCharacter(true);
×
45
            if ($character === null) {
×
46
                break;
×
47
            }
48
            $identifier .= $character;
×
49
        }
50
        $useUrl = $parserState->streql($identifier, 'url');
×
51
        if ($useUrl) {
×
52
            $parserState->consumeWhiteSpace();
×
53
            $parserState->consume('(');
×
54
        } else {
55
            $anchor->backtrack();
×
56
        }
57
        $parserState->consumeWhiteSpace();
×
58
        $result = new URL(CSSString::parse($parserState), $parserState->currentLine());
×
59
        if ($useUrl) {
×
60
            $parserState->consumeWhiteSpace();
×
61
            $parserState->consume(')');
×
62
        }
63
        return $result;
×
64
    }
65

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

71
    public function getURL(): CSSString
2✔
72
    {
73
        return $this->url;
2✔
74
    }
75

76
    public function render(OutputFormat $outputFormat): string
×
77
    {
78
        return "url({$this->url->render($outputFormat)})";
×
79
    }
80
}
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