<commit_before><?php

namespace Bootlace\Http\Response\Header;

use Bootlace\DataCollection\DataCollection;

class ServerDataCollection extends DataCollection
{
    const HTTP_HEADER_PREFIX = 'HTTP_';

    const HTTP_NON_PREFIXED_HEADERS = array(
        'CONTENT_LENGTH',
        'CONTENT_TYPE',
        'CONTENT_MD5'
    );

    /**
     * Checks if the given string is prefixed by the given prefix.
     *
     * @param string $name
     * @param string $prefix
     * @return bool
     */
    public static function hasPrefix(string $name, string $prefix = self::HTTP_HEADER_PREFIX): bool
    {
        if (strpos($name, $prefix) === 0) {
            return true;
        }
        return false;
    }

    /**
     * Get our headers from our server data collection.
     *
     * @return array
     */
    public function getHeaders(): array
    {
        $headers = array();
        foreach ($this->attributes as $key => $value) {
            if (self::hasPrefix($key, self::HTTP_HEADER_PREFIX)) {
                $headers[substr($key, strlen(self::HTTP_HEADER_PREFIX))] = $value;
            } elseif (in_array($key, self::HTTP_NON_PREFIXED_HEADERS)) {
                $headers[$key] = $value;
            }
        }
        return $headers;
    }

    /**
     * Alias for getHeaders().
     *
     * @return array
     */
    public function all(): array
    {
        return $this->getHeaders();
    }
}<commit_msg>Server->all() returns all headers now.<commit_after><?php

namespace Bootlace\Http\Response\Header;

use Bootlace\DataCollection\DataCollection;

class ServerDataCollection extends DataCollection
{
    const HTTP_HEADER_PREFIX = 'HTTP_';

    const HTTP_NON_PREFIXED_HEADERS = array(
        'CONTENT_LENGTH',
        'CONTENT_TYPE',
        'CONTENT_MD5'
    );

    /**
     * Checks if the given string is prefixed by the given prefix.
     *
     * @param string $name
     * @param string $prefix
     * @return bool
     */
    public static function hasPrefix(string $name, string $prefix = self::HTTP_HEADER_PREFIX): bool
    {
        if (strpos($name, $prefix) === 0) {
            return true;
        }
        return false;
    }

    /**
     * Get our headers from our server data collection.
     *
     * @return array
     */
    public function getHeaders(): array
    {
        $headers = array();
        foreach ($this->attributes as $key => $value) {
            if (self::hasPrefix($key, self::HTTP_HEADER_PREFIX)) {
                $headers[substr($key, strlen(self::HTTP_HEADER_PREFIX))] = $value;
            } elseif (in_array($key, self::HTTP_NON_PREFIXED_HEADERS)) {
                $headers[$key] = $value;
            }
        }
        return $headers;
    }

    /**
     * Alias for getHeaders().
     *
     * @return array
     */
    public function all(): array
    {
        return $this->attributes;
    }
}
{'fraction_non_alphanumeric': 0.1146773654296222, 'fraction_numerical': 0.0013373453694416582, 'mean_word_length': 1.8631578947368421, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '365264', 'n_tokens_mistral': 883, 'n_tokens_neox': 833, 'n_words': 202}