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

MyIntervals / PHP-CSS-Parser / 13957957423

19 Mar 2025 10:31PM UTC coverage: 51.499%. Remained the same
13957957423

push

github

web-flow
[CLEANUP] And some more annotations for non-empty strings (#1199)

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

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
     */
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
    /**
59
     * @return non-empty-string
60
     */
61
    public function render(OutputFormat $outputFormat): string
×
62
    {
63
        return '@namespace ' . ($this->prefix === null ? '' : $this->prefix . ' ')
×
64
            . $this->url->render($outputFormat) . ';';
×
65
    }
66

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

75
    public function getPrefix(): ?string
×
76
    {
77
        return $this->prefix;
×
78
    }
79

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

88
    public function setPrefix(string $prefix): void
×
89
    {
90
        $this->prefix = $prefix;
×
91
    }
×
92

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

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

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

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

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