Comment.php
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Vendor\Sabberworm\CSS\Comment; |
| 4 | |
| 5 | use Automattic\WooCommerce\Vendor\Sabberworm\CSS\OutputFormat; |
| 6 | use Automattic\WooCommerce\Vendor\Sabberworm\CSS\Renderable; |
| 7 | use Automattic\WooCommerce\Vendor\Sabberworm\CSS\Position\Position; |
| 8 | use Automattic\WooCommerce\Vendor\Sabberworm\CSS\Position\Positionable; |
| 9 | |
| 10 | class Comment implements Positionable, Renderable |
| 11 | { |
| 12 | use Position; |
| 13 | |
| 14 | /** |
| 15 | * @var string |
| 16 | * |
| 17 | * @internal since 8.8.0 |
| 18 | */ |
| 19 | protected $sComment; |
| 20 | |
| 21 | /** |
| 22 | * @param string $sComment |
| 23 | * @param int $iLineNo |
| 24 | */ |
| 25 | public function __construct($sComment = '', $iLineNo = 0) |
| 26 | { |
| 27 | $this->sComment = $sComment; |
| 28 | $this->setPosition($iLineNo); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @return string |
| 33 | */ |
| 34 | public function getComment() |
| 35 | { |
| 36 | return $this->sComment; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @param string $sComment |
| 41 | * |
| 42 | * @return void |
| 43 | */ |
| 44 | public function setComment($sComment) |
| 45 | { |
| 46 | $this->sComment = $sComment; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @return string |
| 51 | * |
| 52 | * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. |
| 53 | */ |
| 54 | public function __toString() |
| 55 | { |
| 56 | return $this->render(new OutputFormat()); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @param OutputFormat|null $oOutputFormat |
| 61 | * |
| 62 | * @return string |
| 63 | */ |
| 64 | public function render($oOutputFormat) |
| 65 | { |
| 66 | return '/*' . $this->sComment . '*/'; |
| 67 | } |
| 68 | } |
| 69 |