Sanpi\Behatch\Context\RestContext::printTheCorrespondingCurlCommand PHP Method

printTheCorrespondingCurlCommand() public method

    public function printTheCorrespondingCurlCommand()
    {
        $method = $this->request->getMethod();
        $url = $this->request->getUri();
        $headers = '';
        foreach ($this->request->getServer() as $name => $value) {
            if (substr($name, 0, 5) !== 'HTTP_' && $name !== 'HTTPS') {
                $headers .= " -H '{$name}: {$value}'";
            }
        }
        $data = '';
        $params = $this->request->getParameters();
        if (!empty($params)) {
            $query = http_build_query($params);
            $data = " --data '{$query}'";
        }
        echo "curl -X {$method}{$data}{$headers} '{$url}'";
    }