Process   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFormattedTime() 0 5 1
A getPid() 0 4 1
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