Completed
Push — master ( d5767c...12e29d )
by Michał
01:17
created

Process::getPid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Phppm;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
abstract class Process implements ProcessInterface
8
{
9
    /**
10
     * @var OutputInterface
11
     */
12
    protected $output;
13
14
    /**
15
     * @var int
16
     */
17
    protected $pid;
18
19
    /**
20
     * Process constructor.
21
     * @param OutputInterface $output
22
     */
23
    public function __construct(OutputInterface $output, $worker)
24
    {
25
        $this->output = $output;
26
        $this->pid = getmypid();
27
        $this->worker = $worker;
0 ignored issues
show
Bug introduced by
The property worker does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    protected function getFormattedTime() : string
34
    {
35
        $now = \DateTime::createFromFormat('U.u', microtime(true));
36
        return $now->format("Y-d-m H:i:s.u");
37
    }
38
39
    /**
40
     * @return int
41
     */
42
    public function getPid() : int
43
    {
44
        return $this->pid;
45
    }
46
}
47