JobEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 30
loc 30
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getJob() 4 4 1
A __construct() 5 5 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
namespace BrainExe\Core\EventDispatcher;
4
5
use BrainExe\Core\MessageQueue\Job;
6
use BrainExe\Core\Traits\JsonSerializableTrait;
7
8
/**
9
 * @api
10
 */
11 View Code Duplication
class JobEvent extends AbstractEvent implements PushViaWebsocket
12
{
13
    use JsonSerializableTrait;
14
15
    const ADDED   = 'message_queue.added';
16
    const HANDLED = 'message_queue.handled';
17
18
    /**
19
     * @var Job
20
     */
21
    private $job;
22
23
    /**
24
     * @param string $type
25
     * @param Job $job
26
     */
27 3
    public function __construct(string $type, Job $job)
28
    {
29 3
        parent::__construct($type);
30 3
        $this->job  = $job;
31 3
    }
32
33
    /**
34
     * @return Job
35
     */
36 1
    public function getJob() : Job
37
    {
38 1
        return $this->job;
39
    }
40
}
41