<commit_before><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Rougin\Slytherin\Http;

use Psr\Http\Message\StreamInterface;

/**
 * Message
 *
 * @package Slytherin
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 */
class Message implements \Psr\Http\Message\MessageInterface
{
    /**
     * @var \Psr\Http\Message\StreamInterface
     */
    private $body;

    /**
     * @var array
     */
    private $headers = array();

    /**
     * @var string
     */
    private $version = '1.1';

    /**
     * @param \Psr\Http\Message\StreamInterface|null $body
     * @param array                                  $headers
     * @param string                                 $version
     */
    public function __construct(StreamInterface $body = null, array $headers = array(), $version = '1.1')
    {
        $this->headers = $headers;

        $this->version = $version;

        $this->body = ($body === null) ? new Stream(fopen('php://temp', 'r+')) : $body;
    }

    /**
     * Retrieves the HTTP protocol version as a string.
     *
     * @return string
     */
    public function getProtocolVersion()
    {
        return $this->version;
    }

    /**
     * Return an instance with the specified HTTP protocol version.
     *
     * @param  string $version
     * @return static
     */
    public function withProtocolVersion($version)
    {
        $this->version = $version;

        return clone $this;
    }

    /**
     * Retrieves all message header values.
     *
     * @return string[][]
     */
    public function getHeaders()
    {
        return $this->headers;
    }

    /**
     * Retrieves a message header value by the given case-insensitive name.
     *
     * @param  string $name
     * @return string[]
     */
    public function hasHeader($name)
    {
        return isset($this->headers[$name]);
    }

    /**
     * Retrieves a message header value by the given case-insensitive name.
     *
     * @param  string $name
     * @return string[]
     */
    public function getHeader($name)
    {
        return $this->hasHeader($name) ? $this->headers[$name] : array();
    }

    /**
     * Retrieves a comma-separated string of the values for a single header.
     *
     * @param  string $name
     * @return string
     */
    public function getHeaderLine($name)
    {
        return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : '';
    }

    /**
     * Return an instance with the provided value replacing the specified header.
     *
     * @throws \InvalidArgumentException
     *
     * @param  string          $name
     * @param  string|string[] $value
     * @return static
     */
    public function withHeader($name, $value)
    {
        $this->headers[$name] = is_string($value) ? array($value) : $value;<commit_msg>Update Http\Message<commit_after><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Rougin\Slytherin\Http;

use Psr\Http\Message\StreamInterface;

/**
 * Message
 *
 * @package Slytherin
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 */
class Message implements \Psr\Http\Message\MessageInterface
{
    /**
     * @var \Psr\Http\Message\StreamInterface
     */
    private $body;

    /**
     * @var array
     */
    private $headers = array();

    /**
     * @var string
     */
    private $version = '1.1';

    /**
     * @param \Psr\Http\Message\StreamInterface|null $body
     * @param array                                  $headers
     * @param string                                 $version
     */
    public function __construct(StreamInterface $body = null, array $headers = array(), $version = '1.1')
    {
        $this->headers = $headers;

        $this->version = $version;

        $this->body = ($body === null) ? new Stream(fopen('php://temp', 'r+')) : $body;
    }

    /**
     * Retrieves the HTTP protocol version as a string.
     *
     * @return string
     */
    public function getProtocolVersion()
    {
        return $this->version;
    }

    /**
     * Return an instance with the specified HTTP protocol version.
     *
     * @param  string $version
     * @return static
     */
    public function withProtocolVersion($version)
    {
        $this->version = $version;

        return clone $this;
    }

    /**
     * Retrieves all message header values.
     *
     * @return string[][]
     */
    public function getHeaders()
    {
        return $this->headers;
    }

    /**
     * Retrieves a message header value by the given case-insensitive name.
     *
     * @param  string $name
     * @return string[]
     */
    public function hasHeader($name)
    {
        return isset($this->headers[$name]);
    }

    /**
     * Retrieves a message header value by the given case-insensitive name.
     *
     * @param  string $name
     * @return string[]
     */
    public function getHeader($name)
    {
        return $this->hasHeader($name) ? $this->headers[$name] : array();
    }

    /**
     * Retrieves a comma-separated string of the values for a single header.
     *
     * @param  string $name
     * @return string
     */
    public function getHeaderLine($name)
    {
        return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : '';
    }

    /**
     * Return an instance with the provided value replacing the specified header.
     *
     * @throws \InvalidArgumentException
     *
     * @param  string          $name
     * @param  string|string[] $value
     * @return static
     */
    public function withHeader($name, $value)
    {
        $this->headers[$name] = array($value);
{'fraction_non_alphanumeric': 0.13296352328122374, 'fraction_numerical': 0.0013447638258530846, 'mean_word_length': 2.000504286434695, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7446518', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1717, 'n_words': 468}