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

MemberId   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 4 1
A __construct() 0 5 1
A userId() 0 4 1
A organizationId() 0 4 1
A equals() 0 4 2
A __toString() 0 4 1
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