ProjectAlreadyExists   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromId() 0 9 1
A fromSlugs() 0 10 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