compare() public static method

주어진 키워드와 기준이 되는 키워드의 등급의 높낮이 비교
public static compare ( string $type, string $criterion ) : integer
$type string target rating keyword
$criterion string criterion keyword
return integer
Example #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;
 }
 /**
  * getGrant
  *
  * @param $user
  *
  * @return array
  */
 protected function getGrant($user)
 {
     $logged = Auth::user();
     $grant = ['modify' => false, 'manage' => false];
     if ($logged->getId() === $user->getId()) {
         $grant['modify'] = true;
     }
     if (Rating::compare($logged->getRating(), Rating::MANAGER) >= 0) {
         $grant['manage'] = true;
         $grant['modify'] = true;
         return $grant;
     }
     return $grant;
 }
Example #3
0
 /**
  * @expectedException \Xpressengine\User\Exceptions\UnknownCriterionException
  */
 public function testCampareThrowException()
 {
     Rating::compare(Rating::MEMBER, 'foo');
 }
Example #4
0
 /**
  * Finds whether user has manager or super rating.
  *
  * @return boolean
  */
 public function isManager()
 {
     return Rating::compare($this->getRating(), Rating::MANAGER) >= 0;
 }