Completed
Pull Request — master (#172)
by Gorka
05:15
created

DoctrineMember   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 20
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A id() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Member;
18
use Kreta\TaskManager\Domain\Model\Organization\MemberId;
19
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId;
20
use Kreta\TaskManager\Domain\Model\User\UserId;
21
22 View Code Duplication
class DoctrineMember extends Member
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...
23
{
24
    protected $surrogateUserId;
25
    protected $surrogateOrganizationId;
26
27
    public function __construct(MemberId $id)
28
    {
29
        parent::__construct($id);
0 ignored issues
show
Bug introduced by
The call to Member::__construct() misses some required arguments starting with $userId.
Loading history...
30
        $this->surrogateUserId = $id->userId()->id();
0 ignored issues
show
Bug introduced by
The method userId() does not seem to exist on object<Kreta\TaskManager...\Organization\MemberId>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        $this->surrogateOrganizationId = $id->organizationId()->id();
0 ignored issues
show
Bug introduced by
The method organizationId() does not seem to exist on object<Kreta\TaskManager...\Organization\MemberId>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
    }
33
34
    public function id() : MemberId
35
    {
36
        return MemberId::generate(
37
            UserId::generate($this->surrogateUserId),
38
            OrganizationId::generate($this->surrogateOrganizationId)
0 ignored issues
show
Unused Code introduced by
The call to MemberId::generate() has too many arguments starting with \Kreta\TaskManager\Domai...urrogateOrganizationId).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
39
        );
40
    }
41
}
42