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

dragomano / scss-php / 23594295754

26 Mar 2026 12:19PM UTC coverage: 84.536%. First build
23594295754

push

github

web-flow
Merge pull request #51 from dragomano/refactor

Rewrite compiler

10140 of 12016 new or added lines in 162 files covered. (84.39%)

10272 of 12151 relevant lines covered (84.54%)

83.37 hits per line

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

94.12
/src/Values/SassString.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Bugo\SCSS\Values;
6

7
use function str_contains;
8
use function strlen;
9

10
final class SassString extends AbstractSassValue
11
{
12
    public function __construct(
13
        private readonly string $value,
14
        private readonly bool $quoted = false
15
    ) {}
372 ✔
16

17
    public function toCss(): string
18
    {
19
        if (! $this->quoted) {
369 ✔
20
            return $this->value;
346 ✔
21
        }
22

23
        $quote = $this->preferredQuote();
35 ✔
24

25
        return $quote . $this->escapeQuotedValue($quote) . $quote;
35 ✔
26
    }
27

28
    public function isTruthy(): bool
29
    {
30
        return true;
3 ✔
31
    }
32

33
    private function preferredQuote(): string
34
    {
35
        if (str_contains($this->value, '"') && ! str_contains($this->value, "'")) {
35 ✔
36
            return "'";
2 ✔
37
        }
38

39
        return '"';
34 ✔
40
    }
41

42
    private function escapeQuotedValue(string $quote): string
43
    {
44
        $result = '';
35 ✔
45
        $length = strlen($this->value);
35 ✔
46

47
        for ($index = 0; $index < $length; $index++) {
35 ✔
48
            $char = $this->value[$index];
34 ✔
49

50
            if ($char === $quote) {
34 ✔
NEW
51
                $result .= '\\';
×
52
            }
53

54
            $result .= $char;
34 ✔
55
        }
56

57
        return $result;
35 ✔
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc