protected function hasData(array $parents)
    {
        $countryCode = $parents[0];
        $addressFormat = $this->addressFormatRepository->get($countryCode);
        $depth = $addressFormat->getSubdivisionDepth();
        if ($depth == 0) {
            return false;
        }
        // At least the first level has data.
        $hasData = true;
        if (count($parents) > 1) {
            // After the first level it is possible for predefined subdivisions
            // to exist at a given level, but not for that specific parent.
            // That's why the parent definition has the most precise answer.
            $grandparents = $parents;
            $parentId = array_pop($grandparents);
            $parentGroup = $this->buildGroup($grandparents);
            if (isset($this->definitions[$parentGroup]['subdivisions'][$parentId])) {
                $definition = $this->definitions[$parentGroup]['subdivisions'][$parentId];
                $hasData = !empty($definition['has_children']);
            } else {
                // The parent definition wasn't loaded previously, fallback
                // to guessing based on depth.
                $neededDepth = count($parents);
                $hasData = ($neededDepth <= $depth);
            }
        }
        return $hasData;
    }
protected function hasData(array $parents)
    {
        $countryCode = $parents[0];
        $addressFormat = $this->addressFormatRepository->get($countryCode);
        $depth = $addressFormat->getSubdivisionDepth();
        if ($depth == 0) {
            return false;
        }
        // At least the first level has data.
        $hasData = true;
        if (count($parents) > 1) {
            // After the first level it is possible for predefined subdivisions
            // to exist at a given level, but not for that specific parent.
            // That's why the parent definition has the most precise answer.
            $grandparents = $parents;
            $parentId = array_pop($grandparents);
            $parentGroup = $this->buildGroup($grandparents);
            if (isset($this->definitions[$parentGroup]['subdivisions'][$parentId])) {
                $definition = $this->definitions[$parentGroup]['subdivisions'][$parentId];
                $hasData = !empty($definition['has_children']);
            } else {
                // The parent definition wasn't loaded previously, fallback
                // to guessing based on depth.
                $neededDepth = count($parents);
                $hasData = ($neededDepth <= $depth);
            }
        }
        return $hasData;
    }
protected function hasData ( array $ parents ) { $ countryCode = $ parents [ 0 ] ; $ addressFormat = $ this -> addressFormatRepository -> get ( $ countryCode ) ; $ depth = $ addressFormat -> getSubdivisionDepth ( ) ; if ( $ depth == 0 ) { return false ; } // At least the first level has data. $ hasData = true ; if ( count ( $ parents ) > 1 ) { // After the first level it is possible for predefined subdivisions // to exist at a given level, but not for that specific parent. // That's why the parent definition has the most precise answer. $ grandparents = $ parents ; $ parentId = array_pop ( $ grandparents ) ; $ parentGroup = $ this -> buildGroup ( $ grandparents ) ; if ( isset ( $ this -> definitions [ $ parentGroup ] [ 'subdivisions' ] [ $ parentId ] ) ) { $ definition = $ this -> definitions [ $ parentGroup ] [ 'subdivisions' ] [ $ parentId ] ; $ hasData = ! empty ( $ definition [ 'has_children' ] ) ; } else { // The parent definition wasn't loaded previously, fallback // to guessing based on depth. $ neededDepth = count ( $ parents ) ; $ hasData = ( $ neededDepth <= $ depth ) ; } } return $ hasData ; }
Checks whether predefined subdivisions exist for the provided parents.

@param array $parents The parents (country code, subdivision codes).

@return bool TRUE if predefined subdivisions exist for the provided
parents, FALSE otherwise.
Checks whether predefined subdivisions exist for the provided parents .