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

MyIntervals / PHP-CSS-Parser / 13630179707

03 Mar 2025 11:48AM UTC coverage: 56.519% (+0.7%) from 55.808%
13630179707

Pull #1046

github

web-flow
Merge ab450d0c0 into 86aeaa791
Pull Request #1046: [TASK] Remove `__toString()`

1049 of 1856 relevant lines covered (56.52%)

12.38 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 array<array-key, 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, $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
    /**
67
     * @return string
68
     */
69
    public function getCharset()
×
70
    {
71
        return $this->charset->getString();
×
72
    }
73

74
    public function render(OutputFormat $outputFormat): string
×
75
    {
76
        return "{$outputFormat->comments($this)}@charset {$this->charset->render($outputFormat)};";
×
77
    }
78

79
    public function atRuleName(): string
×
80
    {
81
        return 'charset';
×
82
    }
83

84
    /**
85
     * @return string
86
     */
87
    public function atRuleArgs()
×
88
    {
89
        return $this->charset;
×
90
    }
91

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

100
    /**
101
     * @return array<array-key, Comment>
102
     */
103
    public function getComments(): array
×
104
    {
105
        return $this->comments;
×
106
    }
107

108
    /**
109
     * @param array<array-key, Comment> $comments
110
     */
111
    public function setComments(array $comments): void
×
112
    {
113
        $this->comments = $comments;
×
114
    }
×
115
}
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