CommerceGuys\Addressing\Subdivision\SubdivisionRepository::buildGroup PHP Method

buildGroup() protected method

Used for storing a country's subdivisions of a specific level.
protected buildGroup ( array $parents ) : string
$parents array The parents (country code, subdivision codes).
return string The group.
    protected function buildGroup(array $parents)
    {
        if (empty($parents)) {
            throw new \InvalidArgumentException('The $parents argument must not be empty.');
        }
        $countryCode = array_shift($parents);
        $group = $countryCode;
        if ($parents) {
            // A dash per key allows the depth to be guessed later.
            $group .= str_repeat('-', count($parents));
            // Hash the remaining keys to ensure that the group is ASCII safe.
            // crc32b is the fastest but has collisions due to its short length.
            // sha1 and md5 are forbidden by many projects and organizations.
            // This is the next fastest option.
            $group .= hash('tiger128,3', implode('-', $parents));
        }
        return $group;
    }