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

MyIntervals / PHP-CSS-Parser / 13888689221

17 Mar 2025 12:01AM UTC coverage: 56.87% (+0.9%) from 55.929%
13888689221

push

github

web-flow
[TASK] Remove `__toString()` (#1046)

Closes #998

1043 of 1834 relevant lines covered (56.87%)

12.89 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

10
/**
11
 * `CSSNamespace` represents an `@namespace` rule.
12
 */
13
class CSSNamespace implements AtRule
14
{
15
    /**
16
     * @var string
17
     */
18
    private $url;
19

20
    /**
21
     * @var string
22
     */
23
    private $prefix;
24

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

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

37
    /**
38
     * @param string $url
39
     * @param string|null $prefix
40
     * @param int<0, max> $lineNumber
41
     */
42
    public function __construct($url, $prefix = null, int $lineNumber = 0)
×
43
    {
44
        $this->url = $url;
×
45
        $this->prefix = $prefix;
×
46
        $this->lineNumber = $lineNumber;
×
47
    }
×
48

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

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

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

71
    /**
72
     * @return string|null
73
     */
74
    public function getPrefix()
×
75
    {
76
        return $this->prefix;
×
77
    }
78

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

87
    /**
88
     * @param string $prefix
89
     */
90
    public function setPrefix($prefix): void
×
91
    {
92
        $this->prefix = $prefix;
×
93
    }
×
94

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

103
    /**
104
     * @return array<int, string>
105
     */
106
    public function atRuleArgs(): array
×
107
    {
108
        $result = [$this->url];
×
109
        if ($this->prefix) {
×
110
            \array_unshift($result, $this->prefix);
×
111
        }
112
        return $result;
×
113
    }
114

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

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

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