/** * @param User $user * @throws \InvalidArgumentException if user isn't valid * @throws \DomainException if username is taken */ public function create(User $user) { if (!$user->isValid()) { throw new \InvalidArgumentException('User is not valid'); } if ($this->getByUsername($user->getUsername())) { throw new \DomainException('Username is taken'); } $this->database->insert($user); }
/** * @param Token $token */ public function insert(Token $token) { $this->database->insert($token); }