← All changes
|
back/Libraries/Sabberworm/CSS/src/Comment/Comment.php
+23
-45
10.0.1
→
11.1.0
View file →
| @@ -1,71 +1,49 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace Sabberworm\CSS\Comment; | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | -use Sabberworm\CSS\OutputFormat; | |
| 6 | -use Sabberworm\CSS\Renderable; | |
| 5 | +namespace AcyMailing\Libraries\Sabberworm\CSS\Comment; | |
| 7 | 6 | |
| 8 | -class Comment implements Renderable | |
| 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 | |
| 9 | 13 | { |
| 10 | - /** | |
| 11 | - * @var int | |
| 12 | - */ | |
| 13 | - protected $iLineNo; | |
| 14 | + use Position; | |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * @var string |
| 18 | + * | |
| 19 | + * @internal since 8.8.0 | |
| 17 | 20 | */ |
| 18 | - protected $sComment; | |
| 21 | + protected $commentText; | |
| 19 | 22 | |
| 20 | 23 | /** |
| 21 | - * @param string $sComment | |
| 22 | - * @param int $iLineNo | |
| 24 | + * @param int<1, max>|null $lineNumber | |
| 23 | 25 | */ |
| 24 | - public function __construct($sComment = '', $iLineNo = 0) | |
| 26 | + public function __construct(string $commentText = '', ?int $lineNumber = null) | |
| 25 | 27 | { |
| 26 | - $this->sComment = $sComment; | |
| 27 | - $this->iLineNo = $iLineNo; | |
| 28 | + $this->commentText = $commentText; | |
| 29 | + $this->setPosition($lineNumber); | |
| 28 | 30 | } |
| 29 | 31 | |
| 30 | - /** | |
| 31 | - * @return string | |
| 32 | - */ | |
| 33 | - public function getComment() | |
| 32 | + public function getComment(): string | |
| 34 | 33 | { |
| 35 | - return $this->sComment; | |
| 34 | + return $this->commentText; | |
| 36 | 35 | } |
| 37 | 36 | |
| 38 | - /** | |
| 39 | - * @return int | |
| 40 | - */ | |
| 41 | - public function getLineNo() | |
| 37 | + public function setComment(string $commentText): void | |
| 42 | 38 | { |
| 43 | - return $this->iLineNo; | |
| 39 | + $this->commentText = $commentText; | |
| 44 | 40 | } |
| 45 | 41 | |
| 46 | 42 | /** |
| 47 | - * @param string $sComment | |
| 48 | - * | |
| 49 | - * @return void | |
| 43 | + * @return non-empty-string | |
| 50 | 44 | */ |
| 51 | - public function setComment($sComment) | |
| 45 | + public function render(OutputFormat $outputFormat): string | |
| 52 | 46 | { |
| 53 | - $this->sComment = $sComment; | |
| 54 | - } | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * @return string | |
| 58 | - */ | |
| 59 | - public function __toString() | |
| 60 | - { | |
| 61 | - return $this->render(new OutputFormat()); | |
| 62 | - } | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * @return string | |
| 66 | - */ | |
| 67 | - public function render(OutputFormat $oOutputFormat) | |
| 68 | - { | |
| 69 | - return '/*' . $this->sComment . '*/'; | |
| 47 | + return '/*' . $this->commentText . '*/'; | |
| 70 | 48 | } |
| 71 | 49 | } |