3  * SPDX-License-Identifier: GPL-2.0-only
 
   5  * This file is part of Nominatim. (https://nominatim.org)
 
   7  * Copyright (C) 2022 by the Nominatim developer community.
 
   8  * For a full list of authors see the git log.
 
  14  * Description of the position of a token within a query.
 
  27     public function __construct($sPhraseType, $iPhrase, $iNumPhrases)
 
  29         $this->sPhraseType = $sPhraseType;
 
  30         $this->iPhrase = $iPhrase;
 
  31         $this->iNumPhrases = $iNumPhrases;
 
  34     public function setTokenPosition($iToken, $iNumTokens)
 
  36         $this->iToken = $iToken;
 
  37         $this->iNumTokens = $iNumTokens;
 
  41      * Check if the phrase can be of the given type.
 
  43      * @param string  $sType  Type of phrse requested.
 
  45      * @return True if the phrase is untyped or of the given type.
 
  47     public function maybePhrase($sType)
 
  49         return $this->sPhraseType == '' || $this->sPhraseType == $sType;
 
  53      * Check if the phrase is exactly of the given type.
 
  55      * @param string  $sType  Type of phrse requested.
 
  57      * @return True if the phrase of the given type.
 
  59     public function isPhrase($sType)
 
  61         return $this->sPhraseType == $sType;
 
  65      * Return true if the token is the very first in the query.
 
  67     public function isFirstToken()
 
  69         return $this->iPhrase == 0 && $this->iToken == 0;
 
  73      * Check if the token is the final one in the query.
 
  75     public function isLastToken()
 
  77         return $this->iToken + 1 == $this->iNumTokens && $this->iPhrase + 1 == $this->iNumPhrases;
 
  81      * Check if the current token is part of the first phrase in the query.
 
  83     public function isFirstPhrase()
 
  85         return $this->iPhrase == 0;
 
  89      * Get the phrase position in the query.
 
  91     public function getPhrase()
 
  93         return $this->iPhrase;