Example #1
0
 /**
  * Checks whether the current user follows a specific user.
  *
  * @param User $user
  *
  * @return bool
  */
 public function follows(User $user)
 {
     foreach ($this->following as $following) {
         if ($following->getUsername() === $user->getUsername()) {
             return true;
         }
     }
     return false;
 }
 /**
  * Factory to create a credentials object from a user entity.
  *
  * @param User $user
  *
  * @return $this
  */
 public static function fromEntity(User $user)
 {
     return new static($user->getUsername(), $user->getRoles(), $user->getApiKey(), $user->getLocale());
 }