requestFactory = $requestFactory; $this->url = $url; $this->key = $key; } /** * Test whether remote Shellbox is enabled by configuration. * * @return bool */ public function isEnabled() { return $this->url !== null && strlen( $this->key ); } /** * Get a Shellbox client with the specified options. If remote Shellbox is * not configured (isEnabled() returns false), an exception will be thrown. * * @param array $options Associative array of options: * - timeout: The request timeout in seconds * @return Client * @throws \RuntimeException */ public function getClient( array $options = [] ) { if ( !$this->isEnabled() ) { throw new \RuntimeException( 'To use a remote shellbox to run shell commands, ' . '$wgShellboxUrl and $wgShellboxSecretKey must be configured.' ); } return new Client( new ShellboxHttpClient( $this->requestFactory, $options['timeout'] ?? self::DEFAULT_TIMEOUT ), new Uri( $this->url ), $this->key ); } }