Process   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 1 Features 2
Metric Value
wmc 6
c 6
b 1
f 2
lcom 0
cbo 2
dl 0
loc 73
ccs 16
cts 16
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A build() 0 4 1
A getId() 0 4 1
A getContext() 0 4 1
A setContext() 0 4 1
A getParentId() 0 4 1
1
<?php
2
3
namespace Ndrx\Profiler;
4
5
use Ndrx\Profiler\Context\Contracts\ContextInterface;
6
use Ndrx\Profiler\Events\DispatcherAwareInterface;
7
use Ndrx\Profiler\Events\DispatcherAwareTrait;
8
use Symfony\Component\EventDispatcher\EventDispatcher;
9
10
class Process implements DispatcherAwareInterface
11
{
12
    use DispatcherAwareTrait;
13
14
    /**
15
     * @var string
16
     */
17
    protected $id;
18
19
    /**
20
     * @var string
21
     */
22
    protected $parentId;
23
24
25
    /**
26
     * @var ContextInterface
27
     */
28
    protected $context;
29
30
    /**
31
     * @param string $id
32
     * @param null $parentId
33
     */
34 222
    public function __construct($id = null, $parentId = null)
35
    {
36 222
        $this->id = $id;
37 222
        $this->parentId = $parentId;
38
39 222
        $this->dispatcher = new EventDispatcher();
40 222
    }
41
42
    /**
43
     * @param null $parentId
44
     * @return Process
45
     */
46 222
    public static function build($parentId = null)
47
    {
48 222
        return new self(sha1(microtime() . uniqid()), $parentId);
49
    }
50
51
    /**
52
     * @return string
53
     */
54 184
    public function getId()
55
    {
56 184
        return $this->id;
57
    }
58
59
    /**
60
     * @return ContextInterface
61
     */
62 10
    public function getContext()
63
    {
64 10
        return $this->context;
65
    }
66
67
    /**
68
     * @param ContextInterface $context
69
     */
70 126
    public function setContext($context)
71
    {
72 126
        $this->context = $context;
73 126
    }
74
75
    /**
76
     * @return string
77
     */
78 6
    public function getParentId()
79
    {
80 6
        return $this->parentId;
81
    }
82
}
83