| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sabberworm\CSS\Comment; |
| 5 |
|
| 6 |
use WCPOS\Vendor\Sabberworm\CSS\OutputFormat; |
| 7 |
use WCPOS\Vendor\Sabberworm\CSS\Position\Position; |
| 8 |
use WCPOS\Vendor\Sabberworm\CSS\Position\Positionable; |
| 9 |
use WCPOS\Vendor\Sabberworm\CSS\Renderable; |
| 10 |
use WCPOS\Vendor\Sabberworm\CSS\ShortClassNameProvider; |
| 11 |
class Comment implements Positionable, Renderable |
| 12 |
{ |
| 13 |
use Position; |
| 14 |
use ShortClassNameProvider; |
| 15 |
/** |
| 16 |
* @var string |
| 17 |
* |
| 18 |
* @internal since 8.8.0 |
| 19 |
*/ |
| 20 |
protected $commentText; |
| 21 |
/** |
| 22 |
* @param int<1, max>|null $lineNumber |
| 23 |
*/ |
| 24 |
public function __construct(string $commentText = '', ?int $lineNumber = null) |
| 25 |
{ |
| 26 |
$this->commentText = $commentText; |
| 27 |
$this->setPosition($lineNumber); |
| 28 |
} |
| 29 |
public function getComment() : string |
| 30 |
{ |
| 31 |
return $this->commentText; |
| 32 |
} |
| 33 |
public function setComment(string $commentText) : void |
| 34 |
{ |
| 35 |
$this->commentText = $commentText; |
| 36 |
} |
| 37 |
/** |
| 38 |
* @return non-empty-string |
| 39 |
*/ |
| 40 |
public function render(OutputFormat $outputFormat) : string |
| 41 |
{ |
| 42 |
return '/*' . $this->commentText . '*/'; |
| 43 |
} |
| 44 |
/** |
| 45 |
* @return array<string, bool|int|float|string|array<mixed>|null> |
| 46 |
* |
| 47 |
* @internal |
| 48 |
*/ |
| 49 |
public function getArrayRepresentation() : array |
| 50 |
{ |
| 51 |
return [ |
| 52 |
'class' => $this->getShortClassName(), |
| 53 |
// "contents" is the term used in the W3C specs: |
| 54 |
// https://www.w3.org/TR/CSS22/syndata.html#comments |
| 55 |
'contents' => $this->commentText, |
| 56 |
]; |
| 57 |
} |
| 58 |
} |
| 59 |
|