Start::getData()   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 1
Metric Value
c 1
b 0
f 1
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: 01/11/15
6
 * Time: 23:26
7
 */
8
9
namespace Ndrx\Profiler\Events\Timeline;
10
11
use Symfony\Component\EventDispatcher\Event;
12
13
class Start extends Event
14
{
15
    const EVENT_NAME = 'profiler.timeline_start';
16
17
    /**
18
     * @var mixed
19
     */
20
    protected $data;
21
22
    /**
23
     * @var string
24
     */
25
    protected $label;
26
27
    /**
28
     * @var string
29
     */
30
    protected $key;
31
32
    /**
33
     * @var int
34
     */
35
    protected $timestamp;
36
37
    /**
38
     * Start constructor.
39
     * @param mixed $data
40
     * @param string $label
41
     * @param string $key
42
     * @param float $timestamp
43
     */
44 4
    public function __construct($key, $label, $data = null, $timestamp = null)
45
    {
46 4
        $this->data = $data;
47 4
        $this->label = $label;
48 4
        $this->key = $key;
49 4
        $this->timestamp = $timestamp === null ? microtime(true) : $timestamp;
0 ignored issues
show
Documentation Bug introduced by
The property $timestamp was declared of type integer, but $timestamp === null ? microtime(true) : $timestamp is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
50 4
    }
51
52
53
    /**
54
     * @return mixed
55
     */
56 4
    public function getData()
57
    {
58 4
        return $this->data;
59
    }
60
61
    /**
62
     * @return string
63
     */
64 4
    public function getLabel()
65
    {
66 4
        return $this->label;
67
    }
68
69
    /**
70
     * @return string
71
     */
72 4
    public function getKey()
73
    {
74 4
        return $this->key;
75
    }
76
77
    /**
78
     * @return integer
79
     */
80 4
    public function getTimestamp()
81
    {
82 4
        return $this->timestamp;
83
    }
84
85
    /**
86
     * @return array
87
     */
88 2
    public function toArray()
89
    {
90 2
        return get_object_vars($this);
91
    }
92
}
93