Elastica\Util::replaceBooleanWords PHP Méthode

replaceBooleanWords() public static méthode

Replace the following reserved words (because part of the query language) AND OR NOT.
public static replaceBooleanWords ( string $term ) : string
$term string Query term to replace
Résultat string Replaced query term
    public static function replaceBooleanWords($term)
    {
        $replacementMap = [' AND ' => ' && ', ' OR ' => ' || ', ' NOT ' => ' !'];
        $result = strtr($term, $replacementMap);
        return $result;
    }

Usage Example

Exemple #1
0
 /**
  * @group unit
  * @dataProvider getReplaceBooleanWordsPairs
  */
 public function testReplaceBooleanWords($before, $after)
 {
     $this->assertEquals($after, Util::replaceBooleanWords($before));
 }