We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 28c7d3b commit 8e3d3d3Copy full SHA for 8e3d3d3
src/FeedIo/Reader/Result/UpdateStats.php
@@ -156,9 +156,19 @@ public function getAverageInterval(): int
156
public function getMedianInterval(): int
157
{
158
sort($this->intervals);
159
- $num = floor(count($this->intervals) / 2);
160
161
- return isset($this->intervals[$num]) ? $this->intervals[$num] : 0;
+ $count = count($this->intervals);
+ if ($count === 0) {
162
+ return 0;
163
+ }
164
+
165
+ $num = floor($count / 2);
166
167
+ if ($count % 2 === 0) {
168
+ return intval(floor(($this->intervals[$num - 1] + $this->intervals[$num]) / 2));
169
+ } else {
170
+ return $this->intervals[$num];
171
172
}
173
174
private function computeIntervals(array $dates): array
0 commit comments