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

MyIntervals / PHP-CSS-Parser / 13886385346

16 Mar 2025 06:50PM UTC coverage: 55.906%. Remained the same
13886385346

push

github

web-flow
[TASK] Add native type declarations for `Import` (#1172)

Part of #811

0 of 6 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

1046 of 1871 relevant lines covered (55.91%)

12.68 hits per line

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

0.0
/src/Property/Import.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Sabberworm\CSS\Property;
6

7
use Sabberworm\CSS\Comment\Comment;
8
use Sabberworm\CSS\OutputFormat;
9
use Sabberworm\CSS\Value\URL;
10

11
/**
12
 * Class representing an `@import` rule.
13
 */
14
class Import implements AtRule
15
{
16
    /**
17
     * @var URL
18
     */
19
    private $location;
20

21
    /**
22
     * @var string|null
23
     */
24
    private $mediaQuery;
25

26
    /**
27
     * @var int<0, max>
28
     *
29
     * @internal since 8.8.0
30
     */
31
    protected $lineNumber;
32

33
    /**
34
     * @var array<array-key, Comment>
35
     *
36
     * @internal since 8.8.0
37
     */
38
    protected $comments = [];
39

40
    /**
41
     * @param int<0, max> $lineNumber
42
     */
NEW
43
    public function __construct(URL $location, ?string $mediaQuery, int $lineNumber = 0)
×
44
    {
45
        $this->location = $location;
×
46
        $this->mediaQuery = $mediaQuery;
×
47
        $this->lineNumber = $lineNumber;
×
48
    }
×
49

50
    /**
51
     * @return int<0, max>
52
     */
53
    public function getLineNo(): int
×
54
    {
55
        return $this->lineNumber;
×
56
    }
57

NEW
58
    public function setLocation(URL $location): void
×
59
    {
60
        $this->location = $location;
×
61
    }
×
62

NEW
63
    public function getLocation(): URL
×
64
    {
65
        return $this->location;
×
66
    }
67

68
    /**
69
     * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
70
     */
71
    public function __toString(): string
×
72
    {
73
        return $this->render(new OutputFormat());
×
74
    }
75

76
    public function render(OutputFormat $outputFormat): string
×
77
    {
78
        return $outputFormat->getFormatter()->comments($this) . '@import ' . $this->location->render($outputFormat)
×
79
            . ($this->mediaQuery === null ? '' : ' ' . $this->mediaQuery) . ';';
×
80
    }
81

82
    /**
83
     * @return non-empty-string
84
     */
85
    public function atRuleName(): string
×
86
    {
87
        return 'import';
×
88
    }
89

90
    /**
91
     * @return array{0: URL, 1?: non-empty-string}
92
     */
93
    public function atRuleArgs(): array
×
94
    {
95
        $result = [$this->location];
×
NEW
96
        if (\is_string($this->mediaQuery) && $this->mediaQuery !== '') {
×
NEW
97
            $result[] = $this->mediaQuery;
×
98
        }
99

UNCOV
100
        return $result;
×
101
    }
102

103
    /**
104
     * @param array<array-key, Comment> $comments
105
     */
106
    public function addComments(array $comments): void
×
107
    {
108
        $this->comments = \array_merge($this->comments, $comments);
×
109
    }
×
110

111
    /**
112
     * @return array<array-key, Comment>
113
     */
114
    public function getComments(): array
×
115
    {
116
        return $this->comments;
×
117
    }
118

119
    /**
120
     * @param array<array-key, Comment> $comments
121
     */
122
    public function setComments(array $comments): void
×
123
    {
124
        $this->comments = $comments;
×
125
    }
×
126

NEW
127
    public function getMediaQuery(): ?string
×
128
    {
129
        return $this->mediaQuery;
×
130
    }
131
}
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

© 2026 Coveralls, Inc