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

MyIntervals / PHP-CSS-Parser / 13091656165

01 Feb 2025 07:16PM UTC coverage: 45.347%. Remained the same
13091656165

Pull #862

github

web-flow
Merge 34495bb5b into 02d859a7f
Pull Request #862: [TASK] Add accessor tests for `OutputFormat` (part 2)

804 of 1773 relevant lines covered (45.35%)

12.13 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 $oCharset;
25

26
    /**
27
     * @var int
28
     */
29
    protected $lineNumber;
30

31
    /**
32
     * @var array<array-key, Comment>
33
     */
34
    protected $comments;
35

36
    /**
37
     * @param int $lineNumber
38
     */
39
    public function __construct(CSSString $oCharset, $lineNumber = 0)
×
40
    {
41
        $this->oCharset = $oCharset;
×
42
        $this->lineNumber = $lineNumber;
×
43
        $this->comments = [];
×
44
    }
×
45

46
    /**
47
     * @return int
48
     */
49
    public function getLineNo()
×
50
    {
51
        return $this->lineNumber;
×
52
    }
53

54
    /**
55
     * @param string|CSSString $oCharset
56
     */
57
    public function setCharset($sCharset): void
×
58
    {
59
        $sCharset = $sCharset instanceof CSSString ? $sCharset : new CSSString($sCharset);
×
60
        $this->oCharset = $sCharset;
×
61
    }
×
62

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

71
    public function __toString(): string
×
72
    {
73
        return $this->render(new OutputFormat());
×
74
    }
75

76
    public function render(OutputFormat $oOutputFormat): string
×
77
    {
78
        return "{$oOutputFormat->comments($this)}@charset {$this->oCharset->render($oOutputFormat)};";
×
79
    }
80

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

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

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

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

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