2021-02-04 09:02:19 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/* Icinga DB Web | (c) 2021 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Icingadb\Command\Object;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base class for commands adding comments
|
|
|
|
|
*/
|
2023-03-01 05:28:18 -05:00
|
|
|
abstract class WithCommentCommand extends ObjectsCommand
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
|
|
|
|
use CommandAuthor;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Comment
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $comment;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the comment
|
|
|
|
|
*
|
|
|
|
|
* @param string $comment
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function setComment(string $comment): self
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
$this->comment = $comment;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the comment
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function getComment(): string
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
if ($this->comment === null) {
|
|
|
|
|
throw new \LogicException(
|
|
|
|
|
'You are accessing an unset property. Please make sure to set it beforehand.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 09:02:19 -05:00
|
|
|
return $this->comment;
|
|
|
|
|
}
|
|
|
|
|
}
|