Xpressengine\User\Rating::compare PHP Method

compare() public static method

주어진 키워드와 기준이 되는 키워드의 등급의 높낮이 비교
public static compare ( string $type, string $criterion ) : integer
$type string target rating keyword
$criterion string criterion keyword
return integer
    public static function compare($type, $criterion)
    {
        $inKey = array_search($type, static::$ratings);
        $criterionKey = array_search($criterion, static::$ratings);
        if ($criterionKey === false) {
            throw new UnknownCriterionException(compact('criterion'));
        }
        if ($inKey == $criterionKey) {
            return 0;
        }
        return $inKey > $criterionKey ? 1 : -1;
    }

Usage Example

Esempio n. 1
0
 /**
  * User 가 권한이 있는 등급인지 판별
  *
  * @param UserInterface $user      user instance
  * @param string        $criterion user rating keyword
  * @return bool
  */
 protected function ratingInspect(UserInterface $user, $criterion)
 {
     if (Rating::compare($this->userRating($user), $criterion) == -1) {
         return false;
     }
     return true;
 }
All Usage Examples Of Xpressengine\User\Rating::compare