Passed
Push — master ( 1e8995...e0bd2f )
by Tomasz
02:02
created

Profile::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Aggrego\Domain\Profile;
6
7
use Aggrego\Domain\Profile\ValueObject\Name;
8
use Aggrego\Domain\Profile\ValueObject\Version;
9
10
class Profile
11
{
12
    private const SEPARATOR = ':';
13
14
    /** @var Name */
15
    private $name;
16
17
    /** @var Version */
18
    private $version;
19
20
    private function __construct(Name $name, Version $version)
21
    {
22
        $this->name = $name;
23
        $this->version = $version;
24
    }
25
26
    public static function createFrom(string $name, string $version): self
27
    {
28
        return new self(
29
            new Name($name),
30
            new Version($version)
31
        );
32
    }
33
34
    public function equal(self $profile): bool
35
    {
36
        return $this->name->equal($profile->name)
37
            && $this->version->equal($profile->version);
38
    }
39
40
    public function __toString(): string
41
    {
42
        return $this->name->getValue() . self::SEPARATOR . $this->version->getValue();
43
    }
44
}
45