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

MyIntervals / PHP-CSS-Parser / 13957745027

19 Mar 2025 10:15PM UTC coverage: 51.499%. Remained the same
13957745027

Pull #1199

github

web-flow
Merge ddb9a5b22 into 357206220
Pull Request #1199: [CLEANUP] And some more annotations for non-empty strings

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/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
    /**
72
     * @return non-empty-string
73
     */
74
    public function render(OutputFormat $outputFormat): string
×
75
    {
76
        return "{$outputFormat->getFormatter()->comments($this)}@charset {$this->charset->render($outputFormat)};";
×
77
    }
78

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

87
    public function atRuleArgs(): CSSString
×
88
    {
89
        return $this->charset;
×
90
    }
91

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

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

108
    /**
109
     * @param list<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

© 2025 Coveralls, Inc