<commit_before><?php

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

namespace League\ISO3166;

trait ISO3166KeyValidators
{
    /**
     * Assert that input looks like an alpha2 key.
     *
     * @param string $alpha2
     *
     * @throws \InvalidArgumentException if input is not a string.
     * @throws \DomainException if input does not look like an alpha2 key.
     *
     * @return string
     */
    private function guardAgainstInvalidAlpha2($alpha2)
    {
        if (!is_string($alpha2)) {
            throw new \InvalidArgumentException(sprintf('Expected $alpha2 to be of type string, got: %s', gettype($alpha2)));
        }

        if (!preg_match('/^[a-zA-Z]{2}$/', $alpha2)) {
            throw new \DomainException(sprintf('Not a valid alpha2 key: %s', $alpha2));
        }
    }

    /**
     * Assert that input looks like an alpha3 key.
     *
     * @param string $alpha3
     *
     * @throws \InvalidArgumentException if input is not a string.
     * @throws \DomainException if input does not look like an alpha3 key.
     *
     * @return string
     */
    private function guardAgainstInvalidAlpha3($alpha3)
    {
        if (!is_string($alpha3)) {
            throw new \InvalidArgumentException(sprintf('Expected $alpha3 to be of type string, got: %s', gettype($alpha3)));
        }

        if (!preg_match('/^[a-zA-Z]{3}$/', $alpha3)) {
            throw new \DomainException(sprintf('Not a valid alpha3 key: %s', $alpha3));
        }
    }

    /**
     * Assert that input looks like a numeric key.
     *
     * @param string $numeric
     *
     * @throws \InvalidArgumentException if input is not a string.
     * @throws \DomainException if input does not look like a numeric key.
     *
     * @return string
     */
    private function guardAgainstInvalidNumeric($numeric)
    {
        if (!is_string($numeric)) {
            throw new \InvalidArgumentException(sprintf('Expected $numeric to be of type string, got: %s', gettype($numeric)));
        }

        if (!preg_match('/^[0-9]{3}$/', $numeric)) {
            throw new \DomainException(sprintf('Not a valid numeric key: %s', $numeric));
        }
    }
}<commit_msg>fix docblocks<commit_after><?php

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

namespace League\ISO3166;

trait ISO3166KeyValidators
{
    /**
     * Assert that input looks like an alpha2 key.
     *
     * @param string $alpha2
     *
     * @throws \InvalidArgumentException if input is not a string.
     * @throws \DomainException if input does not look like an alpha2 key.
     */
    private function guardAgainstInvalidAlpha2($alpha2)
    {
        if (!is_string($alpha2)) {
            throw new \InvalidArgumentException(sprintf('Expected $alpha2 to be of type string, got: %s', gettype($alpha2)));
        }

        if (!preg_match('/^[a-zA-Z]{2}$/', $alpha2)) {
            throw new \DomainException(sprintf('Not a valid alpha2 key: %s', $alpha2));
        }
    }

    /**
     * Assert that input looks like an alpha3 key.
     *
     * @param string $alpha3
     *
     * @throws \InvalidArgumentException if input is not a string.
     * @throws \DomainException if input does not look like an alpha3 key.
     */
    private function guardAgainstInvalidAlpha3($alpha3)
    {
        if (!is_string($alpha3)) {
            throw new \InvalidArgumentException(sprintf('Expected $alpha3 to be of type string, got: %s', gettype($alpha3)));
        }

        if (!preg_match('/^[a-zA-Z]{3}$/', $alpha3)) {
            throw new \DomainException(sprintf('Not a valid alpha3 key: %s', $alpha3));
        }
    }

    /**
     * Assert that input looks like a numeric key.
     *
     * @param string $numeric
     *
     * @throws \InvalidArgumentException if input is not a string.
     * @throws \DomainException if input does not look like a numeric key.
     */
    private function guardAgainstInvalidNumeric($numeric)
    {
        if (!is_string($numeric)) {
            throw new \InvalidArgumentException(sprintf('Expected $numeric to be of type string, got: %s', gettype($numeric)));
        }

        if (!preg_match('/^[0-9]{3}$/', $numeric)) {
            throw new \DomainException(sprintf('Not a valid numeric key: %s', $numeric));
        }
    }
}
{'fraction_non_alphanumeric': 0.12346505916499219, 'fraction_numerical': 0.015628488501897745, 'mean_word_length': 2.4408602150537635, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '1527126', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1286, 'n_words': 415}