| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 | <?php/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */namespace Symfony\Component\HttpClient;use Symfony\Contracts\HttpClient\HttpClientInterface;/** * A helper providing autocompletion for available options. * * @see HttpClientInterface for a description of each options. * * @author Nicolas Grekas <p@tchwork.com> */class HttpOptions{    private array $options = [];    public function toArray(): array    {        return $this->options;    }    /**     * @return $this     */    public function setAuthBasic(string $user, string $password = ''): static    {        $this->options['auth_basic'] = $user;        if ('' !== $password) {            $this->options['auth_basic'] .= ':'.$password;        }        return $this;    }    /**     * @return $this     */    public function setAuthBearer(string $token): static    {        $this->options['auth_bearer'] = $token;        return $this;    }    /**     * @return $this     */    public function setQuery(array $query): static    {        $this->options['query'] = $query;        return $this;    }    /**     * @return $this     */    public function setHeaders(iterable $headers): static    {        $this->options['headers'] = $headers;        return $this;    }    /**     * @param array|string|resource|\Traversable|\Closure $body     *     * @return $this     */    public function setBody(mixed $body): static    {        $this->options['body'] = $body;        return $this;    }    /**     * @return $this     */    public function setJson(mixed $json): static    {        $this->options['json'] = $json;        return $this;    }    /**     * @return $this     */    public function setUserData(mixed $data): static    {        $this->options['user_data'] = $data;        return $this;    }    /**     * @return $this     */    public function setMaxRedirects(int $max): static    {        $this->options['max_redirects'] = $max;        return $this;    }    /**     * @return $this     */    public function setHttpVersion(string $version): static    {        $this->options['http_version'] = $version;        return $this;    }    /**     * @return $this     */    public function setBaseUri(string $uri): static    {        $this->options['base_uri'] = $uri;        return $this;    }    /**     * @return $this     */    public function buffer(bool $buffer): static    {        $this->options['buffer'] = $buffer;        return $this;    }    /**     * @return $this     */    public function setOnProgress(callable $callback): static    {        $this->options['on_progress'] = $callback;        return $this;    }    /**     * @return $this     */    public function resolve(array $hostIps): static    {        $this->options['resolve'] = $hostIps;        return $this;    }    /**     * @return $this     */    public function setProxy(string $proxy): static    {        $this->options['proxy'] = $proxy;        return $this;    }    /**     * @return $this     */    public function setNoProxy(string $noProxy): static    {        $this->options['no_proxy'] = $noProxy;        return $this;    }    /**     * @return $this     */    public function setTimeout(float $timeout): static    {        $this->options['timeout'] = $timeout;        return $this;    }    /**     * @return $this     */    public function setMaxDuration(float $maxDuration): static    {        $this->options['max_duration'] = $maxDuration;        return $this;    }    /**     * @return $this     */    public function bindTo(string $bindto): static    {        $this->options['bindto'] = $bindto;        return $this;    }    /**     * @return $this     */    public function verifyPeer(bool $verify): static    {        $this->options['verify_peer'] = $verify;        return $this;    }    /**     * @return $this     */    public function verifyHost(bool $verify): static    {        $this->options['verify_host'] = $verify;        return $this;    }    /**     * @return $this     */    public function setCaFile(string $cafile): static    {        $this->options['cafile'] = $cafile;        return $this;    }    /**     * @return $this     */    public function setCaPath(string $capath): static    {        $this->options['capath'] = $capath;        return $this;    }    /**     * @return $this     */    public function setLocalCert(string $cert): static    {        $this->options['local_cert'] = $cert;        return $this;    }    /**     * @return $this     */    public function setLocalPk(string $pk): static    {        $this->options['local_pk'] = $pk;        return $this;    }    /**     * @return $this     */    public function setPassphrase(string $passphrase): static    {        $this->options['passphrase'] = $passphrase;        return $this;    }    /**     * @return $this     */    public function setCiphers(string $ciphers): static    {        $this->options['ciphers'] = $ciphers;        return $this;    }    /**     * @return $this     */    public function setPeerFingerprint(string|array $fingerprint): static    {        $this->options['peer_fingerprint'] = $fingerprint;        return $this;    }    /**     * @return $this     */    public function capturePeerCertChain(bool $capture): static    {        $this->options['capture_peer_cert_chain'] = $capture;        return $this;    }    /**     * @return $this     */    public function setExtra(string $name, mixed $value): static    {        $this->options['extra'][$name] = $value;        return $this;    }}
 |