← All changes
|
back/Libraries/Sabberworm/CSS/src/Comment/Comment.php
+49
-0
10.0.0
→
11.1.0
View file →
| @@ -1,0 +1,49 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +declare(strict_types=1); | |
| 4 | + | |
| 5 | +namespace AcyMailing\Libraries\Sabberworm\CSS\Comment; | |
| 6 | + | |
| 7 | +use AcyMailing\Libraries\Sabberworm\CSS\OutputFormat; | |
| 8 | +use AcyMailing\Libraries\Sabberworm\CSS\Renderable; | |
| 9 | +use AcyMailing\Libraries\Sabberworm\CSS\Position\Position; | |
| 10 | +use AcyMailing\Libraries\Sabberworm\CSS\Position\Positionable; | |
| 11 | + | |
| 12 | +class Comment implements Positionable, Renderable | |
| 13 | +{ | |
| 14 | + use Position; | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * @var string | |
| 18 | + * | |
| 19 | + * @internal since 8.8.0 | |
| 20 | + */ | |
| 21 | + protected $commentText; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * @param int<1, max>|null $lineNumber | |
| 25 | + */ | |
| 26 | + public function __construct(string $commentText = '', ?int $lineNumber = null) | |
| 27 | + { | |
| 28 | + $this->commentText = $commentText; | |
| 29 | + $this->setPosition($lineNumber); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public function getComment(): string | |
| 33 | + { | |
| 34 | + return $this->commentText; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public function setComment(string $commentText): void | |
| 38 | + { | |
| 39 | + $this->commentText = $commentText; | |
| 40 | + } | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * @return non-empty-string | |
| 44 | + */ | |
| 45 | + public function render(OutputFormat $outputFormat): string | |
| 46 | + { | |
| 47 | + return '/*' . $this->commentText . '*/'; | |
| 48 | + } | |
| 49 | +} | |