Completed
Push — master ( 460dcb...effb4b )
by Gorka
06:40
created

ProjectAlreadyExists::fromId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Domain\Model\Project;
16
17
use Kreta\SharedKernel\Domain\Model\Exception;
18
use Kreta\SharedKernel\Domain\Model\Identity\Slug;
19
20
class ProjectAlreadyExists extends Exception
21
{
22
    public static function fromId(ProjectId $projectId) : self
23
    {
24
        return new self(
25
            sprintf(
26
                'Project with "%s" id already exists',
27
                $projectId->id()
28
            )
29
        );
30
    }
31
32
    public static function fromSlugs(Slug $slug, Slug $organizationSlug) : self
33
    {
34
        return new self(
35
            sprintf(
36
                'Project with "%s" slug and "%s" organization\'s slug already exists',
37
                $slug->slug(),
38
                $organizationSlug->slug()
39
            )
40
        );
41
    }
42
}
43