Passed
Push — master ( 657f5c...767802 )
by Ekin
03:11
created

IssuesEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 63.89 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 23
loc 36
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 1
A buildMessage() 9 9 1
A buildSound() 0 8 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 declare(strict_types = 1);
2
3
namespace ekinhbayar\GitAmp\Event\GitHub;
4
5
use ekinhbayar\GitAmp\Event\BaseEvent;
6
use ekinhbayar\GitAmp\Presentation\Information;
7
use ekinhbayar\GitAmp\Presentation\Type;
8
use ekinhbayar\GitAmp\Presentation\Ring;
9
use ekinhbayar\GitAmp\Presentation\Sound\BaseSound;
10
use ekinhbayar\GitAmp\Presentation\Sound\Clav;
11
use ekinhbayar\GitAmp\Presentation\Sound\ClavEgg;
12
13
class IssuesEvent extends BaseEvent
14
{
15 2 View Code Duplication
    public function __construct(array $event)
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 2
        parent::__construct(
18 2
            (int) $event['id'],
19 2
            new Type(3),
20 2
            new Information(
21 2
                $event['payload']['issue']['html_url'],
22 2
                $event['payload']['issue']['title'],
23 2
                $this->buildMessage($event)
24
            ),
25 2
            new Ring(3000, 80),
26 2
            $this->buildSound($event)
27
        );
28
    }
29
30 2 View Code Duplication
    private function buildMessage(array $event): string
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...
31
    {
32 2
        return \sprintf(
33 2
            '%s %s an issue in %s',
34 2
            $event['actor']['login'],
35 2
            $event['payload']['action'],
36 2
            $event['repo']['name']
37
        );
38
    }
39
40 2
    private function buildSound(array $event): BaseSound
41
    {
42 2
        if ($event['repo']['name'] === 'ekinhbayar/gitamp') {
43 1
            return new ClavEgg();
44
        }
45
46 1
        return new Clav(\strlen($event['payload']['issue']['title']) * 1.1);
47
    }
48
}
49