public function calculatePercentage(ScoreSet $scoreSet, $score_type = 'positive'): float { $sentiment_to_type['positive'] = 1; $sentiment_to_type['neutral'] = 0; $sentiment_to_type['negative'] = -1; $countAllScores = $scoreSet->getScores()->count(); $result = $this->filterScoresBySentiment($scoreSet, $sentiment_to_type[$score_type]); if($result > 0) return ($result/$countAllScores) * 100; return 0; }