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

MyIntervals / PHP-CSS-Parser / 13816645941

12 Mar 2025 04:33PM UTC coverage: 55.573% (-0.1%) from 55.68%
13816645941

Pull #898

github

web-flow
Merge 18801d18b into b0238f0a4
Pull Request #898: [TASK] Avoid magic method forwarding in `OutputFormat`

5 of 17 new or added lines in 4 files covered. (29.41%)

1 existing line in 1 file now uncovered.

1042 of 1875 relevant lines covered (55.57%)

12.37 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
     */
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
    /**
67
     * @return string
68
     */
69
    public function getCharset()
×
70
    {
71
        return $this->charset->getString();
×
72
    }
73

74
    /**
75
     * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
76
     */
77
    public function __toString(): string
×
78
    {
79
        return $this->render(new OutputFormat());
×
80
    }
81

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

87
    /**
88
     * @return non-empty-string
89
     */
90
    public function atRuleName(): string
×
91
    {
92
        return 'charset';
×
93
    }
94

95
    /**
96
     * @return string
97
     */
98
    public function atRuleArgs()
×
99
    {
100
        return $this->charset;
×
101
    }
102

103
    /**
104
     * @param array<array-key, Comment> $comments
105
     */
106
    public function addComments(array $comments): void
×
107
    {
108
        $this->comments = \array_merge($this->comments, $comments);
×
109
    }
×
110

111
    /**
112
     * @return array<array-key, Comment>
113
     */
114
    public function getComments(): array
×
115
    {
116
        return $this->comments;
×
117
    }
118

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