Child::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
ccs 0
cts 11
cp 0
rs 9.4286
cc 1
eloc 9
nc 1
nop 4
crap 2
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