code: public function confirmEmail($token)
      {
          /* @var $user UserInterface */
          $user = $this->getMapper()->findOneBy(['registrationToken' => $token]);
          if (!$user instanceof UserInterface) {
              return;
          }
  
          $eventManager = $this->getEventManager();
          $eventManager->trigger(__METHOD__, $this, $user);
  
          $user->setRegistrationToken($this->getRegistrationToken());
          $user->setEmailConfirmed(true);
          $this->getMapper()->update($user)->save();
  
          $eventManager->trigger(__METHOD__ . '.post', $this, $user);
  
          return $user;
      }
docs: Confirm user email
  
  @param string $token
  @return UserInterface|void