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

MyIntervals / PHP-CSS-Parser / 12938832721

23 Jan 2025 09:59PM UTC coverage: 41.942% (+0.6%) from 41.369%
12938832721

Pull #800

github

web-flow
Merge ed97ed250 into 9e79e16ff
Pull Request #800: [FEATURE] Parse color functions with modern syntax

16 of 16 new or added lines in 1 file covered. (100.0%)

864 of 2060 relevant lines covered (41.94%)

6.39 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 $iLineNo;
30

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

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

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

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

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

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

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

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

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

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

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

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