/** * Check if there is user with given username or email address * * @param \User\Entity\User $user * @return bool */ public function exist($user) { if ($user->email == null && $user->user_name == null) { return true; } $criteria = []; if ($user->email) { $criteria[] = ['email' => $user->email]; } if ($user->user_name) { $criteria[] = ['user_name' => $user->user_name]; } $count = $this->userMapper->count(['$or' => $criteria]); return $count > 0; }