Returns true if Rating doesn't belong to any review.

@param Rating          $rating
@param ArrayCollection $reviews

@return bool
323033
private function isRatingWithoutReview(Rating $rating, ArrayCollection $reviews)
    {
        $withoutReview = true;

        foreach ($reviews as $review) {
            if ($this->isReviewRating($review, $rating)) {
                $withoutReview = false;
                break;
            }
        }

        return $withoutReview;
    }
758905
protected function recountRatingOfAllModelTypes()
    {
        $rateableTypes = app(RatingModelContract::class)->select(['rateable_type'])->groupBy('rateable_type')->get();

        foreach ($rateableTypes as $rating) {
            $this->recountRatingOfModelType($rating->rateable_type);
        }
    }
175820
public function deleteRating($userId, $ratingId)
    {
        $rating = $this->getRatingById($ratingId);

        $this->validateUserPermissionsToManageRating($rating, $userId);

        $rating = $this->disableSubShopDeleteProtectionForRating($rating);
        $rating->delete();
    }
579074
private function getRatingById($ratingId)
    {
        $rating = oxNew(Rating::class);
        $doesRatingExist = $rating->load($ratingId);

        if (!$doesRatingExist) {
            throw new EntryDoesNotExistDaoException();
        }

        return $rating;
    }
1123037
public function review($completion, $mark = true) {
        $timeenrolled = $this->get_timeenrolled($completion);

        // If duration since enrollment has passed
        if (!$this->enrolperiod || !$timeenrolled) {
            return false;
        }

        if (time() > ($timeenrolled + $this->enrolperiod)) {
            if ($mark) {
                $completion->mark_complete();
            }

            return true;
        }

        return false;
    }
362758
public function setRating($rating)
    {
        if (!in_array((int) $rating, range(1,5)))
        {
            throw new \Exception('Rating can only be an integer 1-5');
        }

        $this->rating = $rating;
    }
197696
public function reviewSync()
    {
        //find orders to review and register campaign
        $this->orderFactory->create()
            ->createReviewCampaigns();
        //sync reviews
        $result = $this->reviewFactory->create()
            ->sync();

        return $result;
    }
1247868
def _get_rating(self, entry):
        """"""
        r_info = ''
        for string in entry[2].strings:
            r_info += string
        rating, share = r_info.split('/')
        return (rating, share.strip('*'))
837429
public function mergeReviewAndRating(ArrayCollection $reviews, ArrayCollection $ratings)
    {
        $ratingAndReviewList = array_merge(
            $this->getReviewDataWithRating($reviews, $ratings),
            $this->getRatingWithoutReviewData($reviews, $ratings)
        );

        return $this->mapReviewAndRatingList($ratingAndReviewList);
    }
307610
def _node_rating_count(self):
    
    try:
        return self.noderatingcount
    except ObjectDoesNotExist:
        node_rating_count = NodeRatingCount(node=self)
        node_rating_count.save()
        return node_rating_count
384096
public function transform(RatingTotalModel $rating): array
    {
        return [
            'title' => $rating->rateable->title,
            'rating' => $rating->rateable->getRatingAverage(),
            'likes' => $rating->rateable->ratings->where('rating', 5)->count(),
            'dislikes' => $rating->rateable->ratings->where('rating', 0)->count(),
            'actions' => view('admin.module.rating::back.partials.datatables.actions', [
                'href' => $rating->rateable->href,
            ])->render(),
        ];
    }
1161603
public function GetReviewAverageScore($bRecount = false)
    {
        if ($bRecount) {
            $oReviews = $this->GetReviewsPublished();

            return $oReviews->GetAverageScore();
        } else {
            return $this->getProductStatsService()->getStats($this->id)->getReviewAverage();
        }
    }
1249298
protected function validateEditReview()
    {
        $this->setSubmitted('review');
        $this->filterSubmitted(array('text', 'rating'));
        $this->setSubmitted('user_id', $this->uid);
        $this->setSubmitted('update', $this->data_review);
        $this->setSubmitted('product_id', $this->data_product['product_id']);
        $this->setSubmitted('status', (int) $this->config('review_status', 1));

        $this->validateComponent('review');

        return !$this->hasErrors(false);
    }
584940
public function setReviewCollection()
    {
        $customerId = $this->model->getId();
        $collection = $this->reviewCollection->create()
            ->addCustomerFilter($customerId)
            ->setOrder('review_id', 'DESC');

        $this->reviewCollection = $collection;

        return $this;
    }
1018551
public function review($completion, $mark = true) {
        // Get user's course grade
        $grade = $this->get_grade($completion);

        // If user's current course grade is higher than the required pass grade
        if ($this->gradepass && $this->gradepass <= $grade) {
            if ($mark) {
                $completion->gradefinal = $grade;
                $completion->mark_complete();
            }

            return true;
        }

        return false;
    }
1033767
public static function validate($rating)
    {
        if (\is_numeric($rating) && $rating > -0.01 && $rating < 5.01) {
            \preg_match('/([0-9].[0-9])/', $rating, $matches);
            $matches[0] = \floatval($matches[0]);

            return (!empty($matches[0]) && $matches[0] <= 5.0 && $matches[0] >= 0.0) ? $matches[0] : false;
        }

        return false;
    }
1093041
protected function prepare_stars( $rating ) {

		$stars     = [];
		$full_star = (int) floor( $rating );
		$half_star = ( ( $rating - $full_star ) > 0 ) ? true : false;

		for ( $i = 0; $i < $full_star; $i++ ) {
			$stars[] = 'filled';
		}

		if ( $half_star ) {
			$stars[] = 'half';
		}

		for ( $i = 0; $i < ( 5 - $full_star ); $i++ ) {
			$stars[] = 'empty';
		}

		return array_reverse( $stars );
	}