PhpVersion::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 4
cp 0.75
rs 9.4286
cc 2
eloc 3
nc 2
nop 0
crap 2.0625
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 01/11/15
6
 * Time: 20:43
7
 */
8
9
namespace Ndrx\Profiler\Collectors\Data;
10
11
use Ndrx\Profiler\Collectors\Collector;
12
use Ndrx\Profiler\Collectors\Contracts\StartCollectorInterface;
13
use Ndrx\Profiler\Renderer\BarRenderableInterface;
14
15
class PhpVersion extends Collector implements StartCollectorInterface, BarRenderableInterface
16
{
17
    /**
18
     * Fetch data
19
     * @return mixed
20
     */
21 12
    public function resolve()
22
    {
23 12
        $this->data = phpversion();
24 12
    }
25
26 10
    public function validate()
27
    {
28 10
        if (!is_string($this->data)) {
29
            throw new \LogicException('Duration must be a string ' . json_encode($this->data) . ' given');
30
        }
31 10
    }
32
33
    /**
34
     * The path in the final json
35
     * @example
36
     *  path /aa/bb
37
     *  will be transformed to
38
     *  {
39
     *     aa : {
40
     *              bb: <VALUE OF RESOLVE>
41
     *       }
42
     *  }
43
     * @return string
44
     */
45 110
    public function getPath()
46
    {
47 110
        return 'php-version';
48
    }
49
}
50