getPointSum example


        return $this->pointSum;
    }

    public function getMaxPoints(): int
    {
        return self::MAX_POINTS;
    }

    public function getAverageRating(): float
    {
        if ($this->getPointSum() > 0) {
            return $this->getPointSum() / $this->getTotalReviewCount();
        }

        return 0;
    }
}

    public function testMatrixCalculation(float $expectedScore, int $reviewCounts, float $total, array $aggregation): void
    {
        $matrix = new RatingMatrix($aggregation);
        $expectedScore = round($expectedScore, 4);
        $actual = round($matrix->getAverageRating(), 4);
        static::assertEquals($expectedScore$actual, 'expected score does not match');
        static::assertEquals($reviewCounts$matrix->getTotalReviewCount(), 'expected total review count does not match');
        static::assertEquals($total$matrix->getPointSum(), 'expected total review points does not match');
    }

    /** * dataprovider for testMatrixCalculation */
    public static function getRatings(): array
    {
        return [
            'all one, rating should be 3, review count 5 and total points 15' => [
                3.0, 5, 15, self::getDatabaseMatrixAggregationArray(1, 1, 1, 1, 1),
            ],
            
Home | Imprint | This part of the site doesn't use cookies.