src/ShortNumberInfo.php
public function getExampleShortNumberForCost($regionCode, $cost)
    {
        $phoneMetadata = $this->getMetadataForRegion($regionCode);
        if ($phoneMetadata === null) {
            return '';
        }

        /** @var PhoneNumberDesc $desc */
        $desc = null;
        switch ($cost) {
            case ShortNumberCost::TOLL_FREE:
                $desc = $phoneMetadata->getTollFree();
                break;
            case ShortNumberCost::STANDARD_RATE:
                $desc = $phoneMetadata->getStandardRate();
                break;
            case ShortNumberCost::PREMIUM_RATE:
                $desc = $phoneMetadata->getPremiumRate();
                break;
            default:
                // UNKNOWN_COST numbers are computed by the process of elimination from the other cost categories
                break;
        }

        if ($desc !== null && $desc->hasExampleNumber()) {
            return $desc->getExampleNumber();
        }

        return '';
    }
public function getExampleShortNumberForCost($regionCode, $cost)
    {
        $phoneMetadata = $this->getMetadataForRegion($regionCode);
        if ($phoneMetadata === null) {
            return '';
        }

        /** @var PhoneNumberDesc $desc */
        $desc = null;
        switch ($cost) {
            case ShortNumberCost::TOLL_FREE:
                $desc = $phoneMetadata->getTollFree();
                break;
            case ShortNumberCost::STANDARD_RATE:
                $desc = $phoneMetadata->getStandardRate();
                break;
            case ShortNumberCost::PREMIUM_RATE:
                $desc = $phoneMetadata->getPremiumRate();
                break;
            default:
                // UNKNOWN_COST numbers are computed by the process of elimination from the other cost categories
                break;
        }

        if ($desc !== null && $desc->hasExampleNumber()) {
            return $desc->getExampleNumber();
        }

        return '';
    }
public function getExampleShortNumberForCost ( $ regionCode , $ cost ) { $ phoneMetadata = $ this -> getMetadataForRegion ( $ regionCode ) ; if ( $ phoneMetadata === null ) { return '' ; } /** @var PhoneNumberDesc $desc */ $ desc = null ; switch ( $ cost ) { case ShortNumberCost :: TOLL_FREE : $ desc = $ phoneMetadata -> getTollFree ( ) ; break ; case ShortNumberCost :: STANDARD_RATE : $ desc = $ phoneMetadata -> getStandardRate ( ) ; break ; case ShortNumberCost :: PREMIUM_RATE : $ desc = $ phoneMetadata -> getPremiumRate ( ) ; break ; default : // UNKNOWN_COST numbers are computed by the process of elimination from the other cost categories break ; } if ( $ desc !== null && $ desc -> hasExampleNumber ( ) ) { return $ desc -> getExampleNumber ( ) ; } return '' ; }
Gets a valid short number for the specified cost category.

@param string $regionCode the region for which an example short number is needed
@param int $cost the cost category of number that is needed
@return string a valid short number for the specified region and cost category. Returns an empty string
when the metadata does not contain such information, or the cost is UNKNOWN_COST.
Gets a valid short number for the specified cost category .