users = $users; } public function auth($network, $identity): User { if ($user = $this->users->findByNetworkIdentity($network, $identity)) { return $user; } $user = User::signupByNetwork($network, $identity); $this->users->save($user); return $user; } public function attach($id, $network, $identity): void { if ($this->users->findByNetworkIdentity($network, $identity)) { throw new \DomainException('Network is already signed up.'); } $user = $this->users->get($id); $user->attachNetwork($network, $identity); $this->users->save($user); } }