Alcohol\ISO3166\ISO3166::listBy PHP Method

listBy() public method

public listBy ( string $listBy = self::KEY_ALPHA2 ) : Generator
$listBy string
return Generator
    public function listBy($listBy = self::KEY_ALPHA2)
    {
        if (!in_array($listBy, $keys = [self::KEY_ALPHA2, self::KEY_ALPHA3, self::KEY_NUMERIC], true)) {
            throw new \DomainException(sprintf('Invalid value for $indexBy, got "%s", expected one of: %s', $listBy, implode(', ', $keys)));
        }
        foreach ($this->countries as $country) {
            (yield $country[$listBy] => $country);
        }
    }