has( $id ) ) { throw InvalidService::from_service_id( $id ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } /** * Service. * * @var Service $service Service. */ $service = $this->offsetGet( $id ); // Instantiate actual services if they were stored lazily. if ( $service instanceof LazilyInstantiatedService ) { $service = $service->instantiate(); $this->put( $id, $service ); } return $service; } /** * Check whether the container can return a service for the given * identifier. * * @since 1.6.0 * * @param string $id Identifier of the service to look for. */ public function has( string $id ): bool { return $this->offsetExists( $id ); } /** * Put a service into the container for later retrieval. * * @since 1.6.0 * * @param string $id Identifier of the service to put into the * container. * @param Service $service Service to put into the container. */ public function put( string $id, Service $service ): void { $this->offsetSet( $id, $service ); } }