Passed
Push — master ( 2ee0d1...1e8995 )
by Tomasz
03:21
created

Profile   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createFrom() 0 5 1
A __toString() 0 3 1
A getName() 0 3 1
A getVersion() 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
    /** @var Name */
13
    private $name;
14
15
    /** @var Version */
16
    private $version;
17
18
    private function __construct(Name $name, Version $version)
19
    {
20
        $this->name = $name;
21
        $this->version = $version;
22
    }
23
24
    public static function createFrom(string $name, string $version): self
25
    {
26
        return new self(
27
            new Name($name),
28
            new Version($version)
29
        );
30
    }
31
32
    public function getName(): Name
33
    {
34
        return $this->name;
35
    }
36
37
    public function getVersion(): Version
38
    {
39
        return $this->version;
40
    }
41
42
    public function equal(self $profile): bool
43
    {
44
        return $this->name->equal($profile->name)
45
            && $this->version->equal($profile->version);
46
    }
47
48
    public function __toString(): string
49
    {
50
        return sprintf('%s:%s', $this->name->getValue(), $this->version->getValue());
51
    }
52
}
53