Ejemplo n.º 1
0
 /**
  * Match and return degrees value
  *
  * @return float|int
  */
 private function degrees()
 {
     // Reset symbol requirement
     if ($this->nextSymbol === Lexer::T_APOSTROPHE || $this->nextSymbol === Lexer::T_QUOTE) {
         $this->nextSymbol = Lexer::T_DEGREE;
     }
     // If degrees is a float there will be no minutes or seconds
     if ($this->lexer->isNextToken(Lexer::T_FLOAT)) {
         // Get degree value
         $degrees = $this->match(Lexer::T_FLOAT);
         // Degree float values may be followed by degree symbol
         if ($this->lexer->isNextToken(Lexer::T_DEGREE)) {
             $this->match(Lexer::T_DEGREE);
             // Set symbol requirement for next value in pair
             $this->nextSymbol = Lexer::T_DEGREE;
         }
         // Return value
         return $degrees;
     }
     // If degrees isn't a float it must be an integer
     $degrees = $this->number();
     // If integer is not followed by a symbol this value is complete
     if (!$this->symbol()) {
         return $degrees;
     }
     // Grab peek of next token since we can't array dereference result in PHP 5.3
     $glimpse = $this->lexer->glimpse();
     // If a colon hasn't been matched, and next token is a number followed by degree symbol, when tuple separator is space instead of comma, this value is complete
     if (Lexer::T_COLON !== $this->nextSymbol && $this->lexer->isNextTokenAny(array(Lexer::T_INTEGER, Lexer::T_FLOAT)) && Lexer::T_DEGREE === $glimpse['type']) {
         return $degrees;
     }
     // Add minutes to value
     $degrees += $this->minutes();
     // Return value
     return $degrees;
 }