Skip to content

Commit

Permalink
Comparing result of strpos with !==
Browse files Browse the repository at this point in the history
  • Loading branch information
lphuberdeau committed May 28, 2014
1 parent 84f491d commit d423130
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/HireVoice/Neo4j/Query/LuceneQueryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct()

public function addQueryTerm($term, $value, $expr = 'AND', $mode = self::STRICT)
{
if($this->isValidExpression($expr)) {
if ($this->isValidExpression($expr)) {
$method = '_'.strtolower($expr);
$this->$method($term, $value);
}
Expand All @@ -67,12 +67,13 @@ public function _and($term, $value)
public function prepareValue($value)
{
$value = trim($value);
if(strpos($value, ' ')) {
if (false !== strpos($value, ' ')) {
$fl = mb_substr($value, 0, 1, 'UTF-8');
if ($fl != '(')
if ($fl != '(') {
return '"'.$value.'"';
else
} else {
return $value;
}
}
return $value;
}
Expand All @@ -82,7 +83,7 @@ public function prepareValue($value)
*/
public function isValidExpression($expr)
{
if(!array_key_exists($expr, $this->allowedExpressions)) {
if (!array_key_exists($expr, $this->allowedExpressions)) {
throw new \InvalidArgumentException(sprintf('The expression "%s" is not a valid expression', $expr));
}
return true;
Expand All @@ -103,13 +104,13 @@ public function getQuery()
{
$query = '';

foreach($this->allowedExpressions as $expr => $queryExpr) {
foreach ($this->allowedExpressions as $expr => $queryExpr) {
$arguments = $this->_args[$expr];
$inlinedArguments = array();
foreach($arguments as $arg) {
foreach ($arguments as $arg) {
$inlinedArguments[] = $arg['term'].':'.$arg['value'];
}
if('' !== $query) {
if ('' !== $query) {
$query .= $queryExpr;
}
$query .= implode($queryExpr, $inlinedArguments);
Expand Down

0 comments on commit d423130

Please sign in to comment.