Timeline   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 88.24%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 15
c 6
b 0
f 0
lcom 1
cbo 1
dl 0
loc 60
ccs 30
cts 34
cp 0.8824
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 4 1
C getData() 0 43 13
A getIcon() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 22/11/15
6
 * Time: 19:01
7
 */
8
9
namespace Ndrx\Profiler\Renderer\Html\Data;
10
11
use Ndrx\Profiler\Renderer\Html\PageInterface;
12
13
class Timeline extends Collector implements PageInterface
14
{
15
    /**
16
     * @return string
17
     */
18 10
    public function getTitle()
19
    {
20 10
        return 'Timeline';
21
    }
22
23
24 10
    public function getData()
25
    {
26 10
        $data = $this->profile;
27
28 10
        if (!array_key_exists('value', $data) || !is_array($data['value'])) {
29 6
            return [];
30
        }
31
32 4
        $min = false;
33 4
        $max = false;
34
35 4
        foreach ($data['value'] as $key => $item) {
36 2
            if (is_bool($min) || $item['start'] < $min) {
37 2
                $min = $item['start'];
38 2
            }
39
40 2
            if (array_key_exists('end', $item)) {
41 2
                if (is_bool($max) || $item['end'] > $max) {
42 2
                    $max = $item['end'];
43 2
                }
44 2
            }
45 4
        }
46
47 4
        if ($min === 0) {
48 2
            $min = 1;
49 2
        }
50
51
52 4
        if ($max === 0) {
53
            $max = 1;
54
        }
55
56
57 4
        foreach ($data['value'] as $key => $item) {
58 2
            if (!array_key_exists('end', $item)) {
59
                $item['end'] = $max;
60
            }
61 2
            $data['value'][$key]['offset'] = floor((($item['start'] - $min) / $min) * 100);
62 2
            $data['value'][$key]['length'] = floor((($item['end'] - $item['start']) / ($max - $min)) * 100);
63 4
        }
64
65 4
        return $data;
66
    }
67
68 10
    public function getIcon()
69
    {
70 10
        return 'fa-play';
71
    }
72
}
73