Пример #1
0
 public function testAddOperator()
 {
     $term = new SearchableString('teste');
     $termClone = clone $term;
     $expected = $termClone->fuzzy(0.5);
     $where = new WhereGroup();
     $term->processOptions(['fuzzy' => 0.5]);
     $result = $where->add($term)->add($term, 'AND')->getValue();
     $fuzzy = "({$expected} AND {$expected})";
     $this->assertEquals($fuzzy, $result);
 }
Пример #2
0
 /**
  * Process a string value to be searched with $options
  * 
  * @param string|closure $value
  * @param array $options
  * 
  * @return string
  */
 protected function processValue($value, array $options)
 {
     if ($value instanceof Closure) {
         $whereGroup = new WhereGroup();
         $value($whereGroup);
         return $whereGroup->getValue();
     }
     $terms = new SearchableString($value);
     return $terms->processOptions($options)->getValue();
 }