Total Complexity | 9 |
Total Lines | 89 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class Thread |
||
8 | { |
||
9 | const EXIT_STATUS_SUCCESS = 0; |
||
10 | const EXIT_STATUS_ERROR = 1; |
||
11 | |||
12 | /** @var int $pid */ |
||
13 | private $pid; |
||
14 | |||
15 | /** @var string $processName */ |
||
16 | private $processName; |
||
17 | |||
18 | /** @var callable $callback */ |
||
19 | private $callback; |
||
20 | |||
21 | /** |
||
22 | * @return int|null |
||
23 | */ |
||
24 | 2 | public function getPid(): ?int |
|
25 | { |
||
26 | 2 | return $this->pid; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param int $pid |
||
31 | * @return Thread |
||
32 | */ |
||
33 | 7 | public function setPid(int $pid): self |
|
34 | { |
||
35 | 7 | $this->pid = $pid; |
|
36 | |||
37 | 7 | return $this; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | 2 | public function getProcessName(): ?string |
|
44 | { |
||
45 | 2 | return $this->processName; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param string $processName |
||
50 | * @return Thread |
||
51 | */ |
||
52 | 8 | public function setProcessName(string $processName): self |
|
53 | { |
||
54 | 8 | $this->processName = $processName; |
|
55 | |||
56 | 8 | return $this; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return callable |
||
61 | */ |
||
62 | 2 | public function getCallback(): ?callable |
|
63 | { |
||
64 | 2 | return $this->callback; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param callable $callback |
||
69 | * @return Thread |
||
70 | */ |
||
71 | 8 | public function setCallback(callable $callback): self |
|
72 | { |
||
73 | 8 | $this->callback = $callback; |
|
74 | |||
75 | 8 | return $this; |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param string $processName |
||
80 | * @return int |
||
81 | * @throws ThreadException |
||
82 | */ |
||
83 | 3 | public function run(string $processName): int |
|
96 | } |
||
97 | |||
98 | } |
||
99 |