Automattic\WooCommerce\Vendor\League\ISO3166

ISO3166::lookupprivateWC 1.0

Lookup ISO3166-1 data by given identifier.

Looks for a match against the given key for each entry in the dataset.

Method of the class: ISO3166{}

No Hooks.

Returns

Array{name:. string, alpha2: string, alpha3: string, numeric: numeric-string, currency: string[]}

Usage

// private - for code of main (parent) class only
$result = $this->lookup( $key, $value ): array;
$key('name'|'alpha2'|'alpha3'|'numeric') (required)
.
$value(string) (required)
.

ISO3166::lookup() code WC 10.3.6

private function lookup(string $key, string $value): array
{
    $value = mb_strtolower($value);

    foreach ($this->countries as $country) {
        $comparison = mb_strtolower($country[$key]);

        if ($value === $comparison || $value === mb_substr($comparison, 0, mb_strlen($value))) {
            return $country;
        }
    }

    throw new OutOfBoundsException(sprintf('No "%s" key found matching: %s', $key, $value));
}