From 8d1c00d6fa42e407c3122a30cbb43aea1989f2fd Mon Sep 17 00:00:00 2001 From: "cristian.almohalla" Date: Sun, 1 May 2022 21:20:16 +0200 Subject: [PATCH] feat: transform logical filter from filter pair to filter collection --- composer.json | 3 ++- src/Domain/Criteria/LogicFilter.php | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 221c72b..b5056e2 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ }, "require": { "php": "^7.4 | ^8.0", - "pccomponentes/ddd": "^2.0" + "pccomponentes/ddd": "^2.0", + "beberlei/assert": "^3.3" } } diff --git a/src/Domain/Criteria/LogicFilter.php b/src/Domain/Criteria/LogicFilter.php index 8b64380..876b77b 100644 --- a/src/Domain/Criteria/LogicFilter.php +++ b/src/Domain/Criteria/LogicFilter.php @@ -2,24 +2,23 @@ namespace Pccomponentes\Criteria\Domain\Criteria; -abstract class LogicFilter implements FilterInterface -{ - private $left; - private $right; +use Assert\Assert; +use PcComponentes\Ddd\Domain\Model\ValueObject\CollectionValueObject; - public function __construct(FilterInterface $left, FilterInterface $right) +abstract class LogicFilter extends CollectionValueObject implements FilterInterface +{ + /** + * @param FilterInterface[] $items + */ + public static function from(array $items): self { - $this->left = $left; - $this->right = $right; - } + Assert::that($items)->all()->isInstanceOf(FilterInterface::class); - public function left(): FilterInterface - { - return $this->left; + return parent::from($items); } - public function right(): FilterInterface + public static function create(FilterInterface...$items): self { - return $this->right; + return static::from($items); } }