Completed
Push — master ( f18229...3dfc64 )
by Alessandro
04:58
created

LogEvent::getOptions()   A

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 0
Metric Value
c 0
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
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Models;
6
7
/**
8
 * Class LogEvent.
9
 */
10
class LogEvent
11
{
12
    /** @var float */
13
    private $start;
14
    /** @var string */
15
    private $method;
16
    /** @var string */
17
    private $collection;
18
    /** @var array */
19
    private $filters;
20
    /** @var array */
21
    private $data;
22
    /** @var array */
23
    private $options;
24
    /** @var int */
25
    private $executionTime;
26
27
    /**
28
     * LogEvent constructor.
29
     */
30 15
    public function __construct()
31
    {
32 15
        $this->start = 0.0;
33 15
        $this->collection = 'undefined';
34 15
        $this->method = 'undefined';
35 15
        $this->filters = [];
36 15
        $this->data = [];
37 15
        $this->executionTime = 0;
38 15
    }
39
40
    /**
41
     * @return float
42
     */
43 4
    public function getStart(): float
44
    {
45 4
        return $this->start;
46
    }
47
48
    /**
49
     * @param float $start
50
     */
51 2
    public function setStart(float $start)
52
    {
53 2
        $this->start = $start;
54 2
    }
55
56
    /**
57
     * @return string
58
     */
59 2
    public function getCollection(): string
60
    {
61 2
        return $this->collection;
62
    }
63
64
    /**
65
     * @param string $collection
66
     */
67 12
    public function setCollection(string $collection)
68
    {
69 12
        $this->collection = $collection;
70 12
    }
71
72
    /**
73
     * @return string
74
     */
75 1
    public function getMethod(): string
76
    {
77 1
        return $this->method;
78
    }
79
80
    /**
81
     * @param string $method
82
     */
83 11
    public function setMethod(string $method)
84
    {
85 11
        $this->method = $method;
86 11
    }
87
88
    /**
89
     * @return array
90
     */
91 1
    public function getFilters(): array
92
    {
93 1
        return $this->filters;
94
    }
95
96
    /**
97
     * @param array $filters
98
     */
99 10
    public function setFilters($filters)
100
    {
101 10
        $this->filters = $filters ?? [];
102 10
    }
103
104
    /**
105
     * @return array|object
106
     */
107 2
    public function getData()
108
    {
109 2
        return $this->data;
110
    }
111
112
    /**
113
     * @param array|object $data
114
     */
115 12
    public function setData($data)
116
    {
117 12
        $this->data = $data ?? [];
0 ignored issues
show
Documentation Bug introduced by
It seems like $data ?? array() can also be of type object. However, the property $data is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
118 12
    }
119
120
    /**
121
     * @return array
122
     */
123 1
    public function getOptions(): array
124
    {
125 1
        return $this->options;
126
    }
127
128
    /**
129
     * @param array $options
130
     */
131 10
    public function setOptions(array $options)
132
    {
133 10
        $this->options = $options;
134 10
    }
135
136
    /**
137
     * @return float
138
     */
139 4
    public function getExecutionTime(): float
140
    {
141 4
        return $this->executionTime;
142
    }
143
144
    /**
145
     * @param float $executionTime
146
     */
147 4
    public function setExecutionTime(float $executionTime)
148
    {
149 4
        $this->executionTime = $executionTime;
0 ignored issues
show
Documentation Bug introduced by
The property $executionTime was declared of type integer, but $executionTime 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...
150 4
    }
151
}
152