Everyone who may change a task's status (attached subcontractors too) comments on it on the job page. Authors edit and remove their own comments; admin and management may remove anyone's (jobs.remove-any-task-comment). Edited comments show when they were edited, and task cards show the number of comments. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
33 lines
688 B
PHP
33 lines
688 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Jobs\Domain\ValueObjects;
|
|
|
|
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskCommentBody;
|
|
|
|
/**
|
|
* The text of a task comment: line breaks are kept, surrounding blank space
|
|
* is not.
|
|
*/
|
|
final readonly class TaskCommentBody
|
|
{
|
|
public const int MAX_LENGTH = 5000;
|
|
|
|
public string $value;
|
|
|
|
/**
|
|
* @throws InvalidTaskCommentBody
|
|
*/
|
|
public function __construct(string $value)
|
|
{
|
|
$value = trim(str_replace(["\r\n", "\r"], "\n", $value));
|
|
|
|
if ($value === '' || mb_strlen($value) > self::MAX_LENGTH) {
|
|
throw new InvalidTaskCommentBody;
|
|
}
|
|
|
|
$this->value = $value;
|
|
}
|
|
}
|