Completed
Push — master ( c1cd82...4c112d )
by Gorka
03:17
created

MemberId::userId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Organization;
16
17
use Kreta\TaskManager\Domain\Model\User\UserId;
18
19
class MemberId
20
{
21
    protected $userId;
22
    protected $organizationId;
23
24
    public static function generate(UserId $userId, OrganizationId $organizationId)
25
    {
26
        return new static($userId, $organizationId);
27
    }
28
29
    protected function __construct(UserId $userId, OrganizationId $organizationId)
30
    {
31
        $this->userId = $userId;
32
        $this->organizationId = $organizationId;
33
    }
34
35
    public function userId() : UserId
36
    {
37
        return $this->userId;
38
    }
39
40
    public function organizationId()
41
    {
42
        return $this->organizationId;
43
    }
44
45
    public function equals(MemberId $id) : bool
46
    {
47
        return $this->organizationId === $id->organizationId() && $this->userId->id() === $id->userId()->id();
48
    }
49
50
    public function __toString() : string
51
    {
52
        return 'UserId: ' . (string) $this->userId->id() . ', OrganizationId: ' . (string) $this->organizationId()->id();
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
53
    }
54
}
55