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

MyIntervals / PHP-CSS-Parser / 13887216117

16 Mar 2025 08:44PM UTC coverage: 56.87% (+0.8%) from 56.036%
13887216117

Pull #1046

github

web-flow
Merge 7c29bb291 into 4312c56fc
Pull Request #1046: [TASK] Remove `__toString()`

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/Charset.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

11
/**
12
 * Class representing an `@charset` rule.
13
 *
14
 * The following restrictions apply:
15
 * - May not be found in any CSSList other than the Document.
16
 * - May only appear at the very top of a Document’s contents.
17
 * - Must not appear more than once.
18
 */
19
class Charset implements AtRule
20
{
21
    /**
22
     * @var CSSString
23
     */
24
    private $charset;
25

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

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

40
    /**
41
     * @param int<0, max> $lineNumber
42
     */
43
    public function __construct(CSSString $charset, int $lineNumber = 0)
×
44
    {
45
        $this->charset = $charset;
×
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
    /**
58
     * @param string|CSSString $charset
59
     */
60
    public function setCharset($charset): void
×
61
    {
62
        $charset = $charset instanceof CSSString ? $charset : new CSSString($charset);
×
63
        $this->charset = $charset;
×
64
    }
×
65

66
    public function getCharset(): string
×
67
    {
68
        return $this->charset->getString();
×
69
    }
70

71
    public function render(OutputFormat $outputFormat): string
×
72
    {
73
        return "{$outputFormat->getFormatter()->comments($this)}@charset {$this->charset->render($outputFormat)};";
×
74
    }
75

76
    /**
77
     * @return non-empty-string
78
     */
79
    public function atRuleName(): string
×
80
    {
81
        return 'charset';
×
82
    }
83

84
    public function atRuleArgs(): CSSString
×
85
    {
86
        return $this->charset;
×
87
    }
88

89
    /**
90
     * @param list<Comment> $comments
91
     */
92
    public function addComments(array $comments): void
×
93
    {
94
        $this->comments = \array_merge($this->comments, $comments);
×
95
    }
×
96

97
    /**
98
     * @return list<Comment>
99
     */
100
    public function getComments(): array
×
101
    {
102
        return $this->comments;
×
103
    }
104

105
    /**
106
     * @param list<Comment> $comments
107
     */
108
    public function setComments(array $comments): void
×
109
    {
110
        $this->comments = $comments;
×
111
    }
×
112
}
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