Process::getTitle()   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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 21/11/15
6
 * Time: 15:14
7
 */
8
9
namespace Ndrx\Profiler\Renderer\Html;
10
11
use Ndrx\Profiler\ProfilerInterface;
12
use Ndrx\Profiler\Renderer\RenderableInterface;
13
14
class Process extends Renderer
15
{
16
    /**
17
     * @var ProfilerInterface
18
     */
19
    protected $profiler;
20
21
    /**
22
     * Process constructor.
23
     */
24 8
    public function __construct(array $profile, ProfilerInterface $profiler)
25
    {
26 8
        $this->profiler = $profiler;
27
28 8
        parent::__construct($profile);
29 8
    }
30
31
32
    /**
33
     * @return mixed
34
     */
35 8
    public function getTemplate()
36
    {
37 8
        return 'process.html.twig';
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43 8
    public function getData()
44
    {
45 8
        $collectors = [];
46
47 8
        $dataCollectors = $this->profiler->getCollectors();
48 8
        $dataCollectors = call_user_func_array('array_merge', $dataCollectors);
49 8
        foreach ($dataCollectors as $collector) {
50 8
            if ($collector instanceof RenderableInterface) {
51 8
                $renderer = $collector->getRenderer();
52
53 8
                if (!$renderer instanceof PageInterface) {
54 8
                    continue;
55
                }
56
57
                $data = [
58
                    'value' => null
59 6
                ];
60 6 View Code Duplication
                if (array_key_exists($collector->getPath(), $this->profile)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61 2
                    $data['value'] = $this->profile[$collector->getPath()];
62 2
                }
63
64 6
                $collectors[$collector->getName()] = $renderer->setData($data);
65 6
            }
66 8
        }
67
68
        return [
69 8
            'collectors' => $collectors,
70
            // build the bar
71 8
            'bar' => (new Bar($this->profile, $this->profiler))
72 8
        ];
73
    }
74
75
    /**
76
     * @return string
77
     */
78 8
    public function getIcon()
79
    {
80 8
        return 'options';
81
    }
82
83
    /**
84
     * @return string
85
     */
86 8
    public function getTitle()
87
    {
88 8
        return 'Profiler';
89
    }
90
}
91