Completed
Pull Request — master (#384)
by Kristof
08:53
created

DelegateEventHandlingToSpecificMethodTraitWithDomainMessageAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 52.94 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 9
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 9 9 2

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
namespace CultuurNet\UDB3\EventHandling;
4
5
use Broadway\Domain\DomainMessage;
6
use CultuurNet\UDB3\DomainMessageAdapter;
7
8
trait DelegateEventHandlingToSpecificMethodTraitWithDomainMessageAdapter
9
{
10
    use DelegateEventHandlingToSpecificMethodTrait;
11
12
    /**
13
     * {@inheritDoc}
14
     */
15 View Code Duplication
    public function handle(DomainMessage $domainMessage)
0 ignored issues
show
Duplication introduced by
This method 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...
16
    {
17
        $event  = $domainMessage->getPayload();
18
        $method = $this->getHandleMethodName($event);
19
20
        if ($method) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $method of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
21
            $this->$method($event, new DomainMessageAdapter($domainMessage));
22
        }
23
    }
24
}
25