Process::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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