<?php
/**
 * This file is part of CircleRestClientBundle.
 *
 * CircleRestClientBundle is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * CircleRestClientBundle is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CircleRestClientBundle.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace Circle\RestClientBundle\Types;

use Circle\RestClientBundle\Parsers\HTTPHeadersParser;

/**
 * Gets the Response Headers from a Curl Response
 *
 * @author    Timo Linde <info@timo-linde.de>
 * @copyright 2016 TeeAge-Beatz UG
 */
class ResponseHeaders {
    /**
     * Creates Header array from a Response string
     * 
     * @see    https://pecl.php.net/
     * @param  string $curlResponse
     * @param  string $headerSize
     * @return array
     */
    public static function create($curlResponse, $headerSize) { 
        $headers = substr($curlResponse, 0, $headerSize);
        
        return function_exists('http_parse_headers') ? http_parse_headers($headers) : HTTPHeadersParser::parse($headers);
    }
}