Bar::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Ndrx\Profiler\Controllers;
4
5
use Ndrx\Profiler\ProfilerInterface;
6
use Ndrx\Profiler\Renderer\Html\Bar as BarRenderer;
7
8
/**
9
 * Created by PhpStorm.
10
 * User: arnaud
11
 * Date: 21/11/15
12
 * Time: 17:16
13
 */
14
class Bar
15
{
16
17
    /**
18
     * @var ProfilerInterface
19
     */
20
    protected $profiler;
21
22
    /**
23
     * Web constructor.
24
     * @param ProfilerInterface $profiler
25
     */
26 4
    public function __construct(ProfilerInterface $profiler)
27
    {
28 4
        $this->profiler = $profiler;
29 4
    }
30
31
32
    /**
33
     * @param $id
34
     * @return string
35
     */
36 4 View Code Duplication
    public function show($id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
37
    {
38 4
        $profile = $this->objectToArray($this->profiler->getProfile($id));
39 4
        $renderer = new BarRenderer($profile, $this->profiler);
40
41 4
        return $renderer->content();
42
    }
43
44
    /**
45
     * @param $obj
46
     * @return array
47
     */
48 4 View Code Duplication
    protected function objectToArray($obj)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
49
    {
50 4
        if (is_object($obj)) {
51 4
            $obj = (array)$obj;
52 4
        }
53
54 4
        if (is_array($obj)) {
55 4
            $new = array();
56 4
            foreach ($obj as $key => $val) {
57 2
                $new[$key] = $this->objectToArray($val);
58 4
            }
59 4
        } else {
60
            $new = $obj;
61
        }
62
63 4
        return $new;
64
    }
65
}
66