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

Profile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createFrom() 0 5 1
A __toString() 0 3 1
A equal() 0 4 2
A __construct() 0 4 1
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