HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/laminas/laminas-http/src/ClientStatic.php
<?php

/**
 * @see       https://github.com/laminas/laminas-http for the canonical source repository
 * @copyright https://github.com/laminas/laminas-http/blob/master/COPYRIGHT.md
 * @license   https://github.com/laminas/laminas-http/blob/master/LICENSE.md New BSD License
 */

namespace Laminas\Http;

/**
 * Http static client
 */
class ClientStatic
{
    /**
     * @var Client
     */
    protected static $client;

    /**
     * Get the static HTTP client
     *
     * @param array|Traversable $options
     * @return Client
     */
    protected static function getStaticClient($options = null)
    {
        if (! isset(static::$client) || $options !== null) {
            static::$client = new Client(null, $options);
        }
        return static::$client;
    }

    /**
     * HTTP GET METHOD (static)
     *
     * @param  string $url
     * @param  array $query
     * @param  array $headers
     * @param  mixed $body
     * @param  array|Traversable $clientOptions
     * @return Response|bool
     */
    public static function get($url, $query = [], $headers = [], $body = null, $clientOptions = null)
    {
        if (empty($url)) {
            return false;
        }

        $request = new Request();
        $request->setUri($url);
        $request->setMethod(Request::METHOD_GET);

        if (! empty($query) && is_array($query)) {
            $request->getQuery()->fromArray($query);
        }

        if (! empty($headers) && is_array($headers)) {
            $request->getHeaders()->addHeaders($headers);
        }

        if (! empty($body)) {
            $request->setContent($body);
        }

        return static::getStaticClient($clientOptions)->send($request);
    }

    /**
     * HTTP POST METHOD (static)
     *
     * @param  string $url
     * @param  array $params
     * @param  array $headers
     * @param  mixed $body
     * @param  array|Traversable $clientOptions
     * @throws Exception\InvalidArgumentException
     * @return Response|bool
     */
    public static function post($url, $params, $headers = [], $body = null, $clientOptions = null)
    {
        if (empty($url)) {
            return false;
        }

        $request = new Request();
        $request->setUri($url);
        $request->setMethod(Request::METHOD_POST);

        if (! empty($params) && is_array($params)) {
            $request->getPost()->fromArray($params);
        } else {
            throw new Exception\InvalidArgumentException('The array of post parameters is empty');
        }

        if (! isset($headers['Content-Type'])) {
            $headers['Content-Type'] = Client::ENC_URLENCODED;
        }

        if (! empty($headers) && is_array($headers)) {
            $request->getHeaders()->addHeaders($headers);
        }

        if (! empty($body)) {
            $request->setContent($body);
        }

        return static::getStaticClient($clientOptions)->send($request);
    }
}