*/ private static ?ServiceContainer $container = null; /** * Dependency injector object instance. */ private static ?Injector $injector = null; /** * Get a particular service out of the service container. * * @since 1.6.0 * * @param string $service Service ID to retrieve. */ public static function get( string $service ): Service { return self::get_container()->get( $service ); } /** * Check if a particular service has been registered in the service container. * * @since 1.6.0 * * @param string $service Service ID to retrieve. */ public static function has( string $service ): bool { return self::get_container()->has( $service ); } /** * Get an instance of the plugin. * * @since 1.6.0 * * @return Plugin Plugin object instance. */ public static function get_plugin(): Plugin { if ( null === self::$plugin ) { self::$plugin = PluginFactory::create(); } return self::$plugin; } /** * Get an instance of the service container. * * @since 1.6.0 * * @return ServiceContainer Service container object instance. */ public static function get_container(): ServiceContainer { if ( null === self::$container ) { self::$container = self::get_plugin()->get_container(); } return self::$container; } /** * Get an instance of the dependency injector. * * @since 1.6.0 * * @return Injector Dependency injector object instance. */ public static function get_injector(): Injector { if ( null === self::$injector ) { self::$injector = self::get_container()->get( 'injector' ); } return self::$injector; } }