Move boolean logic in is own namespace

This commit is contained in:
Mathieu Darse
2015-11-03 18:42:56 +01:00
parent f1d6141766
commit 652f8be213
5 changed files with 12 additions and 10 deletions

View File

@@ -1,10 +1,10 @@
<?php
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST\Boolean;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
class AndExpression extends BinaryOperator
class AndOperator extends BinaryOperator
{
protected $operator = 'AND';

View File

@@ -1,6 +1,8 @@
<?php
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST\Boolean;
use Alchemy\Phrasea\SearchEngine\Elastic\AST\Node;
abstract class BinaryOperator extends Node
{

View File

@@ -1,10 +1,10 @@
<?php
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST\Boolean;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
class ExceptExpression extends BinaryOperator
class ExceptOperator extends BinaryOperator
{
protected $operator = 'EXCEPT';

View File

@@ -1,10 +1,10 @@
<?php
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST\Boolean;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
class OrExpression extends BinaryOperator
class OrOperator extends BinaryOperator
{
protected $operator = 'OR';

View File

@@ -121,21 +121,21 @@ class QueryVisitor implements Visit
private function visitAndNode(Element $element)
{
return $this->handleBinaryOperator($element, function($left, $right) {
return new AST\AndExpression($left, $right);
return new AST\Boolean\AndOperator($left, $right);
});
}
private function visitOrNode(Element $element)
{
return $this->handleBinaryOperator($element, function($left, $right) {
return new AST\OrExpression($left, $right);
return new AST\Boolean\OrOperator($left, $right);
});
}
private function visitExceptNode(Element $element)
{
return $this->handleBinaryOperator($element, function($left, $right) {
return new AST\ExceptExpression($left, $right);
return new AST\Boolean\ExceptOperator($left, $right);
});
}