Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
1 / 2 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| StringValue | |
50.00% |
1 / 2 |
|
50.00% |
1 / 2 |
2.50 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * A CSS string value, e.g. `"comic sans"` in `font-family`. Named with the |
| 9 | * `Value` suffix to avoid the PHP `string` keyword collision. |
| 10 | */ |
| 11 | final readonly class StringValue extends Value |
| 12 | { |
| 13 | public function __construct(public string $value) {} |
| 14 | |
| 15 | public function toCss(): string |
| 16 | { |
| 17 | return '"' . str_replace('"', '\\"', $this->value) . '"'; |
| 18 | } |
| 19 | } |