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

MyIntervals / PHP-CSS-Parser / 16176944918

09 Jul 2025 06:11PM UTC coverage: 57.958% (+0.02%) from 57.935%
16176944918

Pull #1321

github

web-flow
Merge 2024d46ac into 6dec68e38
Pull Request #1321: [CLEANUP] Use static variable for stop characters

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

1056 of 1822 relevant lines covered (57.96%)

16.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.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\CommentContainer;
8
use Sabberworm\CSS\OutputFormat;
9
use Sabberworm\CSS\Position\Position;
10
use Sabberworm\CSS\Position\Positionable;
11
use Sabberworm\CSS\Value\CSSString;
12

13
/**
14
 * Class representing an `@charset` rule.
15
 *
16
 * The following restrictions apply:
17
 * - May not be found in any CSSList other than the Document.
18
 * - May only appear at the very top of a Document’s contents.
19
 * - Must not appear more than once.
20
 */
21
class Charset implements AtRule, Positionable
22
{
23
    use CommentContainer;
24
    use Position;
25

26
    /**
27
     * @var CSSString
28
     */
29
    private $charset;
30

31
    /**
32
     * @param int<1, max>|null $lineNumber
33
     */
34
    public function __construct(CSSString $charset, ?int $lineNumber = null)
1✔
35
    {
36
        $this->charset = $charset;
1✔
37
        $this->setPosition($lineNumber);
1✔
38
    }
1✔
39

40
    /**
41
     * @param string|CSSString $charset
42
     */
43
    public function setCharset($charset): void
×
44
    {
45
        $charset = $charset instanceof CSSString ? $charset : new CSSString($charset);
×
46
        $this->charset = $charset;
×
47
    }
×
48

49
    public function getCharset(): string
×
50
    {
51
        return $this->charset->getString();
×
52
    }
53

54
    /**
55
     * @return non-empty-string
56
     */
57
    public function render(OutputFormat $outputFormat): string
×
58
    {
59
        return "{$outputFormat->getFormatter()->comments($this)}@charset {$this->charset->render($outputFormat)};";
×
60
    }
61

62
    /**
63
     * @return non-empty-string
64
     */
65
    public function atRuleName(): string
×
66
    {
67
        return 'charset';
×
68
    }
69

70
    public function atRuleArgs(): CSSString
×
71
    {
72
        return $this->charset;
×
73
    }
74
}
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