Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CommentValidationException
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 forEmptyContent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 forInvalidTarget
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Comments\Domain\Exception;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use DomainException;
12
13/**
14 * Exception thrown when comment input data validation fails.
15 *
16 * @package App\Modules\Comments\Domain\Exception
17 */
18final class CommentValidationException extends DomainException
19{
20    public static function forEmptyContent(): self
21    {
22        return new self('Comment content cannot be empty.');
23    }
24
25    public static function forInvalidTarget(string $module, int $recordId): self
26    {
27        return new self(sprintf('Invalid target record: module "%s", ID %d.', $module, $recordId));
28    }
29}