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

MyIntervals / PHP-CSS-Parser / 13270679659

11 Feb 2025 07:12PM UTC coverage: 49.156%. Remained the same
13270679659

Pull #910

github

web-flow
Merge c5f9fd700 into a5d22be77
Pull Request #910: [CLEANUP] Avoid Hungarian notation for `outputFormat`

22 of 58 new or added lines in 18 files covered. (37.93%)

1 existing line in 1 file now uncovered.

932 of 1896 relevant lines covered (49.16%)

11.42 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<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 $oCharset, $lineNumber = 0)
×
44
    {
45
        $this->oCharset = $oCharset;
×
46
        $this->lineNumber = $lineNumber;
×
47
        $this->comments = [];
×
48
    }
×
49

50
    /**
51
     * @return int<0, max>
52
     */
53
    public function getLineNo(): int
×
54
    {
55
        return $this->lineNumber;
×
56
    }
57

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

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

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

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

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

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

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

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

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