result; } public function handle( $remoteURL, $method = 'POST', $data = [] ) { $this->initialize(); $this->setRemoteURL( $remoteURL ); $this->setMethod( $method ); $this->setData( $data ); $this->setCurlOptions(); $this->performRemoteCall(); $this->closeCurl(); // echo $this->result; } private function initialize() { $this->curl = curl_init(); } private function setRemoteURL( $remoteURL ) { $this->remoteURL = $remoteURL; } private function setMethod( $method ) { $this->method = $method; } private function setData( $data ) { $this->data = $data; } private function setCurlOptions() { curl_setopt_array( $this->curl, [ CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $this->remoteURL, CURLOPT_POST => $this->method == 'POST' ? TRUE : FALSE, CURLOPT_POSTFIELDS => $this->data ] ); } private function performRemoteCall() { $this->result = curl_exec( $this->curl ); } private function closeCurl() { curl_close( $this->curl ); } }