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

MyIntervals / PHP-CSS-Parser / 14434074128

13 Apr 2025 10:45PM UTC coverage: 56.257% (+0.03%) from 56.225%
14434074128

Pull #1245

github

web-flow
Merge ac5aec38b into 03ed64a09
Pull Request #1245: [CLEANUP] `allSelectors()` -> `getAllSelectors()`

0 of 4 new or added lines in 2 files covered. (0.0%)

998 of 1774 relevant lines covered (56.26%)

7.91 hits per line

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

50.0
/src/CSSList/Document.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Sabberworm\CSS\CSSList;
6

7
use Sabberworm\CSS\OutputFormat;
8
use Sabberworm\CSS\Parsing\ParserState;
9
use Sabberworm\CSS\Parsing\SourceException;
10
use Sabberworm\CSS\Property\Selector;
11

12
/**
13
 * This class represents the root of a parsed CSS file. It contains all top-level CSS contents: mostly declaration
14
 * blocks, but also any at-rules encountered (`Import` and `Charset`).
15
 */
16
class Document extends CSSBlockList
17
{
18
    /**
19
     * @throws SourceException
20
     *
21
     * @internal since V8.8.0
22
     */
23
    public static function parse(ParserState $parserState): Document
×
24
    {
25
        $document = new Document($parserState->currentLine());
×
26
        CSSList::parseList($parserState, $document);
×
27

28
        return $document;
×
29
    }
30

31
    /**
32
     * Returns all `Selector` objects with the requested specificity found recursively in the tree.
33
     *
34
     * Note that this does not yield the full `DeclarationBlock` that the selector belongs to
35
     * (and, currently, there is no way to get to that).
36
     *
37
     * @param string|null $specificitySearch
38
     *        An optional filter by specificity.
39
     *        May contain a comparison operator and a number or just a number (defaults to "==").
40
     *
41
     * @return list<Selector>
42
     *
43
     * @example `getSelectorsBySpecificity('>= 100')`
44
     */
45
    public function getSelectorsBySpecificity(?string $specificitySearch = null): array
×
46
    {
NEW
47
        return $this->getAllSelectors($specificitySearch);
×
48
    }
49

50
    /**
51
     * Overrides `render()` to make format argument optional.
52
     */
53
    public function render(?OutputFormat $outputFormat = null): string
10✔
54
    {
55
        if ($outputFormat === null) {
10✔
56
            $outputFormat = new OutputFormat();
2✔
57
        }
58
        return $outputFormat->getFormatter()->comments($this) . $this->renderListContents($outputFormat);
10✔
59
    }
60

61
    public function isRootList(): bool
11✔
62
    {
63
        return true;
11✔
64
    }
65
}
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