- if ($aWord['class']) {
- // Special terms need to appear in their normalized form.
- // (postcodes are not normalized in the word table)
- $sNormWord = $this->normalizeString($aWord['word']);
- if ($aWord['word'] && strpos($sNormQuery, $sNormWord) === false) {
- continue;
- }
-
- if ($aWord['class'] == 'place' && $aWord['type'] == 'house') {
- $oToken = new Token\HouseNumber($iId, trim($aWord['word_token']));
- } elseif ($aWord['class'] == 'place' && $aWord['type'] == 'postcode') {
- if ($aWord['word']
+ switch ($aWord['type']) {
+ case 'C': // country name tokens
+ if ($aWord['word'] !== null) {
+ $oValidTokens->addToken(
+ $sTok,
+ new Token\Country($iId, $aWord['word'])
+ );
+ }
+ break;
+ case 'H': // house number tokens
+ $oValidTokens->addToken($sTok, new Token\HouseNumber($iId, $aWord['word_token']));
+ break;
+ case 'P': // postcode tokens
+ // Postcodes are not normalized, so they may have content
+ // that makes SQL injection possible. Reject postcodes
+ // that would need special escaping.
+ if ($aWord['word'] !== null