Passed
Pull Request — master (#9)
by Shinji
01:26
created

TargetProcessList   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 31
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A putOne() 0 3 1
A __construct() 0 3 1
A getArray() 0 3 1
A pickOne() 0 3 1
A getDiff() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Inspector\Daemon\Dispatcher;
15
16
final class TargetProcessList
17
{
18
    /** @var int[] */
19
    private array $pid_list;
20
21
    public function __construct(int ...$pid_list)
22
    {
23
        $this->pid_list = $pid_list;
24
    }
25
26
    public function pickOne(): ?int
27
    {
28
        return array_pop($this->pid_list);
29
    }
30
31
    public function putOne(int $pid): void
32
    {
33
        $this->pid_list[] = $pid;
34
    }
35
36
    public function getDiff(TargetProcessList $compare_list): self
37
    {
38
        return new self(...array_diff($this->pid_list, $compare_list->pid_list));
39
    }
40
41
    /**
42
     * @return int[]
43
     */
44
    public function getArray(): array
45
    {
46
        return $this->pid_list;
47
    }
48
}
49