import { Rating } from './Rating' ; import SensCritiqueLogo from '../../images/services/senscritique' ; import { VideoInfo } from '../http/Client' ; export const SensCritiqueRating = class SensCritiqueRating extends Rating { constructor ( videoInfo ) { super ( ) ; this . videoInfo = videoInfo ; this . logo = SensCritiqueLogo ; this . rating = videoInfo . rating ? this . ratingInPercent ( videoInfo . rating ) : null ; } ratingInPercent ( rawRating ) { if ( rawRating === null || rawRating === undefined || ! rawRating . match ( /^(?:\d{1,2}[,.])?\d{1,2}$/ ) ) { return null ; } rawRating = rawRating . replace ( ',' , '.' ) ; const rating = Number . parseFloat ( rawRating ) ; if ( ! Number . isNaN ( rating ) && ( rating >= 0 && rating <= 10 ) ) { return rating * 10 ; } return null ; } } ;