Skip to content

Commit

Permalink
Release v0.4.2
Browse files Browse the repository at this point in the history
- Bugfix/Now the filters VO is correctly serialized with array values.
  • Loading branch information
othercodes authored Apr 26, 2021
2 parents 550aae2 + 14e6027 commit 9870785
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/Domain/Criteria/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ final protected function invariantOperatorValueMustBeOneOfTheList(): bool
*
* @param string $field
* @param string $operator
* @param mixed $value
* @param mixed $value
*
* @return Filter
*/
Expand Down Expand Up @@ -121,6 +121,13 @@ public function value()

public function __toString(): string
{
return sprintf('%s.%s.%s', $this->field(), $this->operator(), $this->value());
return sprintf(
'%s.%s.%s',
$this->field(),
$this->operator(),
is_array($this->value())
? implode('|', $this->value())
: $this->value()
);
}
}
4 changes: 2 additions & 2 deletions tests/Domain/Criteria/CriteriaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testShouldBuildCriteriaSuccessfully(): void
$criteria = new Criteria(
FilterGroup::create(
[
['name', '=', 'Marsellus'],
['name', 'in', ['Marsellus', 'Mia']],
['surname', '=', 'Wallace'],
]
),
Expand All @@ -44,7 +44,7 @@ public function testShouldBuildCriteriaSuccessfully(): void
$this->assertEquals(100, $criteria->pageOffset());

$this->assertEquals(
"name.=.Marsellus+surname.=.Wallace#name.asc#100.100",
"name.in.Marsellus|Mia+surname.=.Wallace#name.asc#100.100",
(string)$criteria
);
}
Expand Down

0 comments on commit 9870785

Please sign in to comment.