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

MyIntervals / PHP-CSS-Parser / 13505907488

24 Feb 2025 07:11PM UTC coverage: 53.778%. Remained the same
13505907488

push

github

web-flow
[CLEANUP] Avoid Hungarian notation in `Charset` (#982)

Part of #756

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

1025 of 1906 relevant lines covered (53.78%)

12.0 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
     */
NEW
43
    public function __construct(CSSString $charset, $lineNumber = 0)
×
44
    {
NEW
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);
×
NEW
63
        $this->charset = $charset;
×
64
    }
×
65

66
    /**
67
     * @return string
68
     */
69
    public function getCharset()
×
70
    {
NEW
71
        return $this->charset->getString();
×
72
    }
73

74
    public function __toString(): string
×
75
    {
76
        return $this->render(new OutputFormat());
×
77
    }
78

79
    public function render(OutputFormat $outputFormat): string
×
80
    {
NEW
81
        return "{$outputFormat->comments($this)}@charset {$this->charset->render($outputFormat)};";
×
82
    }
83

84
    public function atRuleName(): string
×
85
    {
86
        return 'charset';
×
87
    }
88

89
    /**
90
     * @return string
91
     */
92
    public function atRuleArgs()
×
93
    {
NEW
94
        return $this->charset;
×
95
    }
96

97
    /**
98
     * @param array<array-key, Comment> $comments
99
     */
100
    public function addComments(array $comments): void
×
101
    {
102
        $this->comments = \array_merge($this->comments, $comments);
×
103
    }
×
104

105
    /**
106
     * @return array<array-key, Comment>
107
     */
108
    public function getComments(): array
×
109
    {
110
        return $this->comments;
×
111
    }
112

113
    /**
114
     * @param array<array-key, Comment> $comments
115
     */
116
    public function setComments(array $comments): void
×
117
    {
118
        $this->comments = $comments;
×
119
    }
×
120
}
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