Child   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 71
loc 71
ccs 0
cts 31
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A getLoop() 4 4 1
A getPid() 4 4 1
A getCallback() 4 4 1
A getPriority() 4 4 1
A cancel() 4 4 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 Thruster\Component\EventLoop;
4
5
/**
6
 * Class Child
7
 *
8
 * @package Thruster\Component\EventLoop
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11 View Code Duplication
class Child
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...
12
{
13
    /**
14
     * @var EventLoop
15
     */
16
    protected $loop;
17
18
    /**
19
     * @var int
20
     */
21
    protected $pid;
22
23
    /**
24
     * @var callable
25
     */
26
    protected $callback;
27
28
    /**
29
     * @var int
30
     */
31
    protected $priority;
32
33
    public function __construct(
34
        EventLoop $loop,
35
        int $pid,
36
        callable $callback,
37
        int $priority = 0
38
    ) {
39
        $this->loop = $loop;
40
        $this->pid = $pid;
41
        $this->callback = $callback;
42
        $this->priority = $priority;
43
    }
44
45
    /**
46
     * @return EventLoop
47
     */
48
    public function getLoop()
49
    {
50
        return $this->loop;
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getPid()
57
    {
58
        return $this->pid;
59
    }
60
61
    /**
62
     * @return callable
63
     */
64
    public function getCallback()
65
    {
66
        return $this->callback;
67
    }
68
69
    /**
70
     * @return int
71
     */
72
    public function getPriority()
73
    {
74
        return $this->priority;
75
    }
76
77
    public function cancel()
78
    {
79
        $this->loop->cancelChild($this);
80
    }
81
}
82