public function addRating($videoId, $rating)
    {
        $this->validateRating($rating);
        $customMetaData = $this->getVideo($videoId)->getCustomMetadata();

        $average = $this->getRatingAverage($videoId);
        $count = $this->getRatingCount($videoId);
        $newCount = $count + 1;

        $customMetaData[$this->metadataFieldCount] = $newCount;
        $customMetaData[$this->metadataFieldAverage] = (($average * $count) + $rating) / $newCount;

        $this->storeCustomMetaData($customMetaData, $videoId);
    }
public function addRating($videoId, $rating)
    {
        $this->validateRating($rating);
        $customMetaData = $this->getVideo($videoId)->getCustomMetadata();

        $average = $this->getRatingAverage($videoId);
        $count = $this->getRatingCount($videoId);
        $newCount = $count + 1;

        $customMetaData[$this->metadataFieldCount] = $newCount;
        $customMetaData[$this->metadataFieldAverage] = (($average * $count) + $rating) / $newCount;

        $this->storeCustomMetaData($customMetaData, $videoId);
    }
public function addRating ( $ videoId , $ rating ) { $ this -> validateRating ( $ rating ) ; $ customMetaData = $ this -> getVideo ( $ videoId ) -> getCustomMetadata ( ) ; $ average = $ this -> getRatingAverage ( $ videoId ) ; $ count = $ this -> getRatingCount ( $ videoId ) ; $ newCount = $ count + 1 ; $ customMetaData [ $ this -> metadataFieldCount ] = $ newCount ; $ customMetaData [ $ this -> metadataFieldAverage ] = ( ( $ average * $ count ) + $ rating ) / $ newCount ; $ this -> storeCustomMetaData ( $ customMetaData , $ videoId ) ; }
Increases the count of all ratings by one and calculates a new average rating value.

@param string $videoId
@param int    $rating

@throws \InvalidArgumentException
Increases the count of all ratings by one and calculates a new average rating value .