|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace TreeHouse\IoBundle\Import; |
|
4
|
|
|
|
|
5
|
|
|
class ImportResult |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var int |
|
9
|
|
|
*/ |
|
10
|
|
|
protected $startTime; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var int |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $endTime; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var int |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $success = 0; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var int |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $failed = 0; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var int |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $skipped = 0; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param int $startTime |
|
34
|
|
|
*/ |
|
35
|
6 |
|
public function __construct($startTime = null) |
|
36
|
|
|
{ |
|
37
|
6 |
|
$this->startTime = $startTime ?: microtime(true); |
|
|
|
|
|
|
38
|
6 |
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return int |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getStartTime() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->startTime; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param int $startTime |
|
50
|
|
|
*/ |
|
51
|
|
|
public function setStartTime($startTime) |
|
52
|
|
|
{ |
|
53
|
|
|
$this->startTime = $startTime; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return int |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getEndTime() |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->endTime; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param int $endTime |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setEndTime($endTime) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->endTime = $endTime; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Adds 1 to success. |
|
74
|
|
|
*/ |
|
75
|
4 |
|
public function incrementSuccess() |
|
76
|
|
|
{ |
|
77
|
4 |
|
++$this->success; |
|
78
|
4 |
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param int $success |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setSuccess($success) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->success = $success; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return int |
|
90
|
|
|
*/ |
|
91
|
4 |
|
public function getSuccess() |
|
92
|
|
|
{ |
|
93
|
4 |
|
return $this->success; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Adds 1 to failed. |
|
98
|
|
|
*/ |
|
99
|
4 |
|
public function incrementFailed() |
|
100
|
|
|
{ |
|
101
|
4 |
|
++$this->failed; |
|
102
|
4 |
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param int $failed |
|
106
|
|
|
*/ |
|
107
|
|
|
public function setFailed($failed) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->failed = $failed; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return int |
|
114
|
|
|
*/ |
|
115
|
4 |
|
public function getFailed() |
|
116
|
|
|
{ |
|
117
|
4 |
|
return $this->failed; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @return int |
|
122
|
|
|
*/ |
|
123
|
4 |
|
public function getSkipped() |
|
124
|
|
|
{ |
|
125
|
4 |
|
return $this->skipped; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @param int $skipped |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setSkipped($skipped) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->skipped = $skipped; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Adds 1 to skipped. |
|
138
|
|
|
*/ |
|
139
|
4 |
|
public function incrementSkipped() |
|
140
|
|
|
{ |
|
141
|
4 |
|
++$this->skipped; |
|
142
|
4 |
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Returns the total number of items that were in the feed, whether they were processed or skipped. |
|
146
|
|
|
* |
|
147
|
|
|
* @return int |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getTotal() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->getSkipped() + $this->getProcessed(); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Returns the number of items that were actually handled by the import, as opposed to skipped items. |
|
156
|
|
|
* |
|
157
|
|
|
* @return int |
|
158
|
|
|
*/ |
|
159
|
4 |
|
public function getProcessed() |
|
160
|
|
|
{ |
|
161
|
4 |
|
return $this->getSuccess() + $this->getFailed(); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @return float |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getElapsedTime() |
|
168
|
|
|
{ |
|
169
|
|
|
return microtime(true) - $this->startTime; |
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
|
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
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. 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.