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

Profile::equal()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
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
    /** @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