Completed
Pull Request — master (#163)
by Beñat
05:43
created

DoctrineOwner::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 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\Infrastructure\Domain\Model\Organization;
16
17
use Kreta\TaskManager\Domain\Model\Organization\MemberId;
18
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId;
19
use Kreta\TaskManager\Domain\Model\Organization\Owner;
20
use Kreta\TaskManager\Domain\Model\Organization\OwnerId;
21
use Kreta\TaskManager\Domain\Model\User\UserId;
22
23 View Code Duplication
class DoctrineOwner extends Owner
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    protected $surrogateUserId;
26
    protected $surrogateOrganizationId;
27
28
    public function __construct(OwnerId $id)
29
    {
30
        parent::__construct($id);
31
        $this->surrogateUserId = $id->userId()->id();
32
        $this->surrogateOrganizationId = $id->organizationId()->id();
33
    }
34
35
    public function id() : MemberId
36
    {
37
        return OwnerId::generate(
38
            UserId::generate($this->surrogateUserId),
39
            OrganizationId::generate($this->surrogateOrganizationId)
40
        );
41
    }
42
}
43