/** * * @param Service $service */ public function removeService(AbstractService $service) { if (!isset($this->services[$service->getName()])) { throw InvalidArgumentException("service not in the list"); } unset($this->services[$service->getName()]); if ($service->getUser() === $this) { $service->setUser(null); } return $this; }