for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpEarth\Stats\Collection;
use PhpEarth\Stats\Collection;
use PhpEarth\Stats\Model\Topic;
/**
* Class TopicCollection.
*/
class TopicCollection extends Collection
{
* Get most active topic.
*
* @return null|Topic
public function getMostActiveTopic()
$commentsTopCount = 0;
$mostActiveTopic = null;
foreach ($this->data as $topic) {
if ($topic->getCommentsCount() > $commentsTopCount) {
$commentsTopCount = $topic->getCommentsCount();
$mostActiveTopic = $topic;
}
return $mostActiveTopic;
* Get top topic with most reactions.
* return null|Topic
public function getTopTopic()
$topCount = 0;
$mostLikedTopic = null;
if ($topic->getReactionsCount() > $topCount) {
$topCount = $topic->getReactionsCount();
$mostLikedTopic = $topic;
return $mostLikedTopic;
* Get number of closed topics.
* @return int
public function getClosedTopicsCount()
$count = 0;
if (!$topic->getCanComment()) {
++$count;
return $count;
* Get most shared topic.
public function getMostSharedTopic()
$mostSharedTopic = null;
if ($topic->getSharesCount() > $topCount) {
$topCount = $topic->getSharesCount();
$mostSharedTopic = $topic;
return $mostSharedTopic;