<commit_before><?php

namespace Aidantwoods\SecureHeaders;

use Aidantwoods\SecureHeaders\Headers\RegularHeader;

class HeaderFactory
{
    private static $memberClasses = array(
        'CSPHeader' => array(
            'content-security-policy',
            'content-security-policy-report-only',
            'x-content-security-policy',
            'x-content-security-policy-report-only'
        )
    );

    public static function build($name, $value = '')
    {
        $namespace = __NAMESPACE__.'\\Headers';

        foreach (self::$memberClasses as $class => $headerNames)
        {
            $class = "$namespace\\$class";

            foreach ($headerNames as $headerName)
            {
                if (strtolower($name) === $headerName)
                {
                    return new $class($name, $value);
                }
            }
        }

        return new RegularHeader($name, $value);
    }
}
<commit_msg>swap foreach to in_array<commit_after><?php

namespace Aidantwoods\SecureHeaders;

use Aidantwoods\SecureHeaders\Headers\RegularHeader;

class HeaderFactory
{
    private static $memberClasses = array(
        'CSPHeader' => array(
            'content-security-policy',
            'content-security-policy-report-only',
            'x-content-security-policy',
            'x-content-security-policy-report-only'
        )
    );

    public static function build($name, $value = '')
    {
        $namespace = __NAMESPACE__.'\\Headers';

        foreach (self::$memberClasses as $class => $headerNames)
        {
            $class = "$namespace\\$class";

            if (in_array(strtolower($name), $headerNames, true))
            {
                return new $class($name, $value);
            }
        }

        return new RegularHeader($name, $value);
    }
}

{'fraction_non_alphanumeric': 0.12644947542794036, 'fraction_numerical': 0.0, 'mean_word_length': 1.9320388349514563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '621267', 'n_tokens_mistral': 511, 'n_tokens_neox': 493, 'n_words': 92}