public function parseFormatFromCldr(Locale $locale, $formatType, $formatLength = self::FORMAT_LENGTH_DEFAULT)
    {
        self::validateFormatType($formatType);
        self::validateFormatLength($formatLength);

        if (isset($this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength])) {
            return $this->parsedFormats[$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength]];
        }

        if ($formatLength === self::FORMAT_LENGTH_DEFAULT) {
            $formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength/' . $formatType . 'Format/pattern';
        } else {
            $formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength[@type="' . $formatLength . '"]/' . $formatType . 'Format/pattern';
        }

        $model = $this->cldrRepository->getModelForLocale($locale);
        $format = $model->getElement($formatPath);

        if (empty($format)) {
            throw new Exception\UnableToFindFormatException('Number format was not found. Please check whether CLDR repository is valid.', 1280218995);
        }

        $parsedFormat = $this->parseFormat($format);

        $this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
        return $this->parsedFormats[$format] = $parsedFormat;
    }
public function parseFormatFromCldr(Locale $locale, $formatType, $formatLength = self::FORMAT_LENGTH_DEFAULT)
    {
        self::validateFormatType($formatType);
        self::validateFormatLength($formatLength);

        if (isset($this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength])) {
            return $this->parsedFormats[$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength]];
        }

        if ($formatLength === self::FORMAT_LENGTH_DEFAULT) {
            $formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength/' . $formatType . 'Format/pattern';
        } else {
            $formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength[@type="' . $formatLength . '"]/' . $formatType . 'Format/pattern';
        }

        $model = $this->cldrRepository->getModelForLocale($locale);
        $format = $model->getElement($formatPath);

        if (empty($format)) {
            throw new Exception\UnableToFindFormatException('Number format was not found. Please check whether CLDR repository is valid.', 1280218995);
        }

        $parsedFormat = $this->parseFormat($format);

        $this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
        return $this->parsedFormats[$format] = $parsedFormat;
    }
public function parseFormatFromCldr ( Locale $ locale , $ formatType , $ formatLength = self :: FORMAT_LENGTH_DEFAULT ) { self :: validateFormatType ( $ formatType ) ; self :: validateFormatLength ( $ formatLength ) ; if ( isset ( $ this -> parsedFormatsIndices [ ( string ) $ locale ] [ $ formatType ] [ $ formatLength ] ) ) { return $ this -> parsedFormats [ $ this -> parsedFormatsIndices [ ( string ) $ locale ] [ $ formatType ] [ $ formatLength ] ] ; } if ( $ formatLength === self :: FORMAT_LENGTH_DEFAULT ) { $ formatPath = 'numbers/' . $ formatType . 'Formats/' . $ formatType . 'FormatLength/' . $ formatType . 'Format/pattern' ; } else { $ formatPath = 'numbers/' . $ formatType . 'Formats/' . $ formatType . 'FormatLength[@type="' . $ formatLength . '"]/' . $ formatType . 'Format/pattern' ; } $ model = $ this -> cldrRepository -> getModelForLocale ( $ locale ) ; $ format = $ model -> getElement ( $ formatPath ) ; if ( empty ( $ format ) ) { throw new Exception \ UnableToFindFormatException ( 'Number format was not found. Please check whether CLDR repository is valid.' , 1280218995 ) ; } $ parsedFormat = $ this -> parseFormat ( $ format ) ; $ this -> parsedFormatsIndices [ ( string ) $ locale ] [ $ formatType ] [ $ formatLength ] = $ format ; return $ this -> parsedFormats [ $ format ] = $ parsedFormat ; }
Returns parsed number format basing on locale and desired format length
if provided.

When third parameter ($formatLength) equals 'default', default format for a
locale will be used.

@param Locale $locale
@param string $formatType A type of format (one of constant values)
@param string $formatLength A length of format (one of constant values)
@return array An array representing parsed format
@throws Exception\UnableToFindFormatException When there is no proper format string in CLDR
Returns parsed number format basing on locale and desired format length if provided .