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

MyIntervals / PHP-CSS-Parser / 13921034674

18 Mar 2025 10:32AM UTC coverage: 56.839%. Remained the same
13921034674

push

github

web-flow
[TASK] Add native type declarations for `CSSNamespace` (#1187)

Part of #811

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

1043 of 1835 relevant lines covered (56.84%)

12.88 hits per line

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

0.0
/src/Property/CSSNamespace.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\CSSString;
10
use Sabberworm\CSS\Value\URL;
11

12
/**
13
 * `CSSNamespace` represents an `@namespace` rule.
14
 */
15
class CSSNamespace implements AtRule
16
{
17
    /**
18
     * @var CSSString|URL
19
     */
20
    private $url;
21

22
    /**
23
     * @var string|null
24
     */
25
    private $prefix;
26

27
    /**
28
     * @var int<0, max> $lineNumber
29
     */
30
    private $lineNumber;
31

32
    /**
33
     * @var list<Comment>
34
     *
35
     * @internal since 8.8.0
36
     */
37
    protected $comments = [];
38

39
    /**
40
     * @param CSSString|URL $url
41
     * @param int<0, max> $lineNumber
42
     */
NEW
43
    public function __construct($url, ?string $prefix = null, int $lineNumber = 0)
×
44
    {
45
        $this->url = $url;
×
46
        $this->prefix = $prefix;
×
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

58
    public function render(OutputFormat $outputFormat): string
×
59
    {
60
        return '@namespace ' . ($this->prefix === null ? '' : $this->prefix . ' ')
×
61
            . $this->url->render($outputFormat) . ';';
×
62
    }
63

64
    /**
65
     * @return CSSString|URL
66
     */
67
    public function getUrl()
×
68
    {
69
        return $this->url;
×
70
    }
71

NEW
72
    public function getPrefix(): ?string
×
73
    {
74
        return $this->prefix;
×
75
    }
76

77
    /**
78
     * @param CSSString|URL $url
79
     */
80
    public function setUrl($url): void
×
81
    {
82
        $this->url = $url;
×
83
    }
×
84

NEW
85
    public function setPrefix(string $prefix): void
×
86
    {
87
        $this->prefix = $prefix;
×
88
    }
×
89

90
    /**
91
     * @return non-empty-string
92
     */
93
    public function atRuleName(): string
×
94
    {
95
        return 'namespace';
×
96
    }
97

98
    /**
99
     * @return array{0: CSSString|URL|non-empty-string, 1?: CSSString|URL}
100
     */
101
    public function atRuleArgs(): array
×
102
    {
103
        $result = [$this->url];
×
NEW
104
        if (\is_string($this->prefix) && $this->prefix !== '') {
×
105
            \array_unshift($result, $this->prefix);
×
106
        }
107
        return $result;
×
108
    }
109

110
    /**
111
     * @param list<Comment> $comments
112
     */
113
    public function addComments(array $comments): void
×
114
    {
115
        $this->comments = \array_merge($this->comments, $comments);
×
116
    }
×
117

118
    /**
119
     * @return list<Comment>
120
     */
121
    public function getComments(): array
×
122
    {
123
        return $this->comments;
×
124
    }
125

126
    /**
127
     * @param list<Comment> $comments
128
     */
129
    public function setComments(array $comments): void
×
130
    {
131
        $this->comments = $comments;
×
132
    }
×
133
}
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