There's a problem with the filter filterBestVotedImage(). If all the images it filter through have a voteAverage of 0, then it will return null whereas it should return the first occurrence of a 0 value.
Possible fix is to set the $voteAverage to -1 as initial value like this:
public function filterBestVotedImage()
{
$currentImage = null;
$voteAverage = -1;
/**
* @var $image Image
*/
foreach ($this->data as $image) {
if ($image->getVoteAverage() > $voteAverage) {
$voteAverage = $image->getVoteAverage();
$currentImage = $image;
}
}
return $currentImage;
}
There's a problem with the filter filterBestVotedImage(). If all the images it filter through have a voteAverage of 0, then it will return null whereas it should return the first occurrence of a 0 value.
Possible fix is to set the $voteAverage to -1 as initial value like this: