public function send(string $method, string $path)
    {
        //extract the meta data
        $data = $this->data;
        $query = $this->query;
        $agent = $this->meta['agent'];
        $headers = $this->headers;

        //permutation groups
        $postable = $method === CurlHandler::METHOD_POST || $method === CurlHandler::METHOD_PUT;
        $custom = $method != CurlHandler::METHOD_GET && $method != CurlHandler::METHOD_POST;

        //resolve the data
        //if the method is a put or post
        if ($postable) {
            //figure out how to encode it
            switch ($this->meta['request']) {
                case CurlHandler::ENCODE_JSON:
                    $data = json_encode($data);
                    break;
                case CurlHandler::ENCODE_QUERY:
                default:
                    $data = http_build_query($data);
                    break;
            }
        //it's a get or delete
        } else {
            //let the data be the query
            $query = array_merge($data, $query);
        }

        //form the url
        $url = $this->host . $path;

        //if we have a query
        if (!empty($query)) {
            //add it on to the url
            $url .= '?' . http_build_query($query);
        }

        // send it into curl
        $request = CurlHandler::i($this->map)
            ->setUrl($url)
            // sets connection timeout to 10 sec.
            ->setConnectTimeout(10)
            // sets the follow location to true
            ->setFollowLocation(true)
            // set page timeout to 60 sec
            ->setTimeout(60)
            // verifying Peer must be boolean
            ->verifyPeer(false)
            //if the agent is set
            ->when($agent, function () use ($agent) {
                // set USER_AGENT
                $this->setUserAgent($agent);
            })
            //if there are headers
            ->when(!empty($headers), function () use ($headers) {
                // set headers
                $this->setHeaders($headers);
            })
            //set the custom request
            ->when($custom, function () use ($method) {
                $this->setCustomRequest($method);
            })
            //when post or put
            ->when($postable, function () use ($data) {
                if (empty($data)) {
                    return;
                }

                //set the post data
                $this->setPostFields($data);
            });

        //how should we return the data ?
        switch ($this->meta['response']) {
            case CurlHandler::ENCODE_QUERY:
                $response = $request->getQueryResponse(); // get the query response
                break;
            case CurlHandler::ENCODE_JSON:
                $response = $request->getJsonResponse(); // get the json response
                break;
            case CurlHandler::ENCODE_XML:
                $response = $request->getSimpleXmlResponse(); // get the xml response
                break;
            case CurlHandler::ENCODE_RAW:
            default:
                $response = $request->getResponse(); // get the raw response
                break;
        }

        //reset paths
        $this->paths = [];

        return $response;
    }
public function send(string $method, string $path)
    {
        //extract the meta data
        $data = $this->data;
        $query = $this->query;
        $agent = $this->meta['agent'];
        $headers = $this->headers;

        //permutation groups
        $postable = $method === CurlHandler::METHOD_POST || $method === CurlHandler::METHOD_PUT;
        $custom = $method != CurlHandler::METHOD_GET && $method != CurlHandler::METHOD_POST;

        //resolve the data
        //if the method is a put or post
        if ($postable) {
            //figure out how to encode it
            switch ($this->meta['request']) {
                case CurlHandler::ENCODE_JSON:
                    $data = json_encode($data);
                    break;
                case CurlHandler::ENCODE_QUERY:
                default:
                    $data = http_build_query($data);
                    break;
            }
        //it's a get or delete
        } else {
            //let the data be the query
            $query = array_merge($data, $query);
        }

        //form the url
        $url = $this->host . $path;

        //if we have a query
        if (!empty($query)) {
            //add it on to the url
            $url .= '?' . http_build_query($query);
        }

        // send it into curl
        $request = CurlHandler::i($this->map)
            ->setUrl($url)
            // sets connection timeout to 10 sec.
            ->setConnectTimeout(10)
            // sets the follow location to true
            ->setFollowLocation(true)
            // set page timeout to 60 sec
            ->setTimeout(60)
            // verifying Peer must be boolean
            ->verifyPeer(false)
            //if the agent is set
            ->when($agent, function () use ($agent) {
                // set USER_AGENT
                $this->setUserAgent($agent);
            })
            //if there are headers
            ->when(!empty($headers), function () use ($headers) {
                // set headers
                $this->setHeaders($headers);
            })
            //set the custom request
            ->when($custom, function () use ($method) {
                $this->setCustomRequest($method);
            })
            //when post or put
            ->when($postable, function () use ($data) {
                if (empty($data)) {
                    return;
                }

                //set the post data
                $this->setPostFields($data);
            });

        //how should we return the data ?
        switch ($this->meta['response']) {
            case CurlHandler::ENCODE_QUERY:
                $response = $request->getQueryResponse(); // get the query response
                break;
            case CurlHandler::ENCODE_JSON:
                $response = $request->getJsonResponse(); // get the json response
                break;
            case CurlHandler::ENCODE_XML:
                $response = $request->getSimpleXmlResponse(); // get the xml response
                break;
            case CurlHandler::ENCODE_RAW:
            default:
                $response = $request->getResponse(); // get the raw response
                break;
        }

        //reset paths
        $this->paths = [];

        return $response;
    }
public function send ( string $ method , string $ path ) { //extract the meta data $ data = $ this -> data ; $ query = $ this -> query ; $ agent = $ this -> meta [ 'agent' ] ; $ headers = $ this -> headers ; //permutation groups $ postable = $ method === CurlHandler :: METHOD_POST || $ method === CurlHandler :: METHOD_PUT ; $ custom = $ method != CurlHandler :: METHOD_GET && $ method != CurlHandler :: METHOD_POST ; //resolve the data //if the method is a put or post if ( $ postable ) { //figure out how to encode it switch ( $ this -> meta [ 'request' ] ) { case CurlHandler :: ENCODE_JSON : $ data = json_encode ( $ data ) ; break ; case CurlHandler :: ENCODE_QUERY : default : $ data = http_build_query ( $ data ) ; break ; } //it's a get or delete } else { //let the data be the query $ query = array_merge ( $ data , $ query ) ; } //form the url $ url = $ this -> host . $ path ; //if we have a query if ( ! empty ( $ query ) ) { //add it on to the url $ url .= '?' . http_build_query ( $ query ) ; } // send it into curl $ request = CurlHandler :: i ( $ this -> map ) -> setUrl ( $ url ) // sets connection timeout to 10 sec. -> setConnectTimeout ( 10 ) // sets the follow location to true -> setFollowLocation ( true ) // set page timeout to 60 sec -> setTimeout ( 60 ) // verifying Peer must be boolean -> verifyPeer ( false ) //if the agent is set -> when ( $ agent , function ( ) use ( $ agent ) { // set USER_AGENT $ this -> setUserAgent ( $ agent ) ; } ) //if there are headers -> when ( ! empty ( $ headers ) , function ( ) use ( $ headers ) { // set headers $ this -> setHeaders ( $ headers ) ; } ) //set the custom request -> when ( $ custom , function ( ) use ( $ method ) { $ this -> setCustomRequest ( $ method ) ; } ) //when post or put -> when ( $ postable , function ( ) use ( $ data ) { if ( empty ( $ data ) ) { return ; } //set the post data $ this -> setPostFields ( $ data ) ; } ) ; //how should we return the data ? switch ( $ this -> meta [ 'response' ] ) { case CurlHandler :: ENCODE_QUERY : $ response = $ request -> getQueryResponse ( ) ; // get the query response break ; case CurlHandler :: ENCODE_JSON : $ response = $ request -> getJsonResponse ( ) ; // get the json response break ; case CurlHandler :: ENCODE_XML : $ response = $ request -> getSimpleXmlResponse ( ) ; // get the xml response break ; case CurlHandler :: ENCODE_RAW : default : $ response = $ request -> getResponse ( ) ; // get the raw response break ; } //reset paths $ this -> paths = [ ] ; return $ response ; }
Sends off this request to cURL

@param string $method
@param string $path
@param array  $meta

@return mixed
Sends off this request to cURL