HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/league/iso3166/src/Guards.php
<?php

/*
 * (c) Rob Bast <rob.bast@gmail.com>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace League\ISO3166;

use League\ISO3166\Exception\DomainException;
use League\ISO3166\Exception\InvalidArgumentException;

final class Guards
{
    /**
     * Assert that input looks like a name key.
     *
     * @param string $name
     *
     * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string
     */
    public static function guardAgainstInvalidName($name)
    {
        if (!is_string($name)) {
            throw new InvalidArgumentException(
                sprintf('Expected $name to be of type string, got: %s', gettype($name))
            );
        }
    }

    /**
     * Assert that input looks like an alpha2 key.
     *
     * @param string $alpha2
     *
     * @throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string
     * @throws \League\ISO3166\Exception\DomainException if input does not look like an alpha2 key
     */
    public static 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 \League\ISO3166\Exception\InvalidArgumentException if input is not a string
     * @throws \League\ISO3166\Exception\DomainException if input does not look like an alpha3 key
     */
    public static 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 \League\ISO3166\Exception\InvalidArgumentException if input is not a string
     * @throws \League\ISO3166\Exception\DomainException if input does not look like a numeric key
     */
    public static 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)
            );
        }
    }
}