src/AsYouTypeFormatter.php
private function maybeCreateNewTemplate()
    {
        // When there are multiple available formats, the formatter uses the first format where a
        // formatting template could be created.
        foreach ($this->possibleFormats as $key => $numberFormat) {
            $pattern = $numberFormat->getPattern();
            if ($this->currentFormattingPattern == $pattern) {
                return false;
            }
            if ($this->createFormattingTemplate($numberFormat)) {
                $this->currentFormattingPattern = $pattern;
                $nationalPrefixSeparatorsMatcher = new Matcher(self::$nationalPrefixSeparatorsPattern,
                    $numberFormat->getNationalPrefixFormattingRule());
                $this->shouldAddSpaceAfterNationalPrefix = $nationalPrefixSeparatorsMatcher->find();
                // With a new formatting template, the matched position using the old template
                // needs to be reset.
                $this->lastMatchPosition = 0;
                return true;
            }

            // Remove the current number format from $this->possibleFormats
            unset($this->possibleFormats[$key]);
        }
        $this->ableToFormat = false;
        return false;
    }
private function maybeCreateNewTemplate()
    {
        // When there are multiple available formats, the formatter uses the first format where a
        // formatting template could be created.
        foreach ($this->possibleFormats as $key => $numberFormat) {
            $pattern = $numberFormat->getPattern();
            if ($this->currentFormattingPattern == $pattern) {
                return false;
            }
            if ($this->createFormattingTemplate($numberFormat)) {
                $this->currentFormattingPattern = $pattern;
                $nationalPrefixSeparatorsMatcher = new Matcher(self::$nationalPrefixSeparatorsPattern,
                    $numberFormat->getNationalPrefixFormattingRule());
                $this->shouldAddSpaceAfterNationalPrefix = $nationalPrefixSeparatorsMatcher->find();
                // With a new formatting template, the matched position using the old template
                // needs to be reset.
                $this->lastMatchPosition = 0;
                return true;
            }

            // Remove the current number format from $this->possibleFormats
            unset($this->possibleFormats[$key]);
        }
        $this->ableToFormat = false;
        return false;
    }
private function maybeCreateNewTemplate ( ) { // When there are multiple available formats, the formatter uses the first format where a // formatting template could be created. foreach ( $ this -> possibleFormats as $ key => $ numberFormat ) { $ pattern = $ numberFormat -> getPattern ( ) ; if ( $ this -> currentFormattingPattern == $ pattern ) { return false ; } if ( $ this -> createFormattingTemplate ( $ numberFormat ) ) { $ this -> currentFormattingPattern = $ pattern ; $ nationalPrefixSeparatorsMatcher = new Matcher ( self :: $ nationalPrefixSeparatorsPattern , $ numberFormat -> getNationalPrefixFormattingRule ( ) ) ; $ this -> shouldAddSpaceAfterNationalPrefix = $ nationalPrefixSeparatorsMatcher -> find ( ) ; // With a new formatting template, the matched position using the old template // needs to be reset. $ this -> lastMatchPosition = 0 ; return true ; } // Remove the current number format from $this->possibleFormats unset ( $ this -> possibleFormats [ $ key ] ) ; } $ this -> ableToFormat = false ; return false ; }
Returns true if a new template is created as opposed to reusing the existing template.
@return bool
Returns true if a new template is created as opposed to reusing the existing template .