Skip to content

Commit 9870785

Browse files
authored
Release v0.4.2
- Bugfix/Now the filters VO is correctly serialized with array values.
2 parents 550aae2 + 14e6027 commit 9870785

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Domain/Criteria/Filter.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ final protected function invariantOperatorValueMustBeOneOfTheList(): bool
8787
*
8888
* @param string $field
8989
* @param string $operator
90-
* @param mixed $value
90+
* @param mixed $value
9191
*
9292
* @return Filter
9393
*/
@@ -121,6 +121,13 @@ public function value()
121121

122122
public function __toString(): string
123123
{
124-
return sprintf('%s.%s.%s', $this->field(), $this->operator(), $this->value());
124+
return sprintf(
125+
'%s.%s.%s',
126+
$this->field(),
127+
$this->operator(),
128+
is_array($this->value())
129+
? implode('|', $this->value())
130+
: $this->value()
131+
);
125132
}
126133
}

tests/Domain/Criteria/CriteriaTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testShouldBuildCriteriaSuccessfully(): void
2323
$criteria = new Criteria(
2424
FilterGroup::create(
2525
[
26-
['name', '=', 'Marsellus'],
26+
['name', 'in', ['Marsellus', 'Mia']],
2727
['surname', '=', 'Wallace'],
2828
]
2929
),
@@ -44,7 +44,7 @@ public function testShouldBuildCriteriaSuccessfully(): void
4444
$this->assertEquals(100, $criteria->pageOffset());
4545

4646
$this->assertEquals(
47-
"name.=.Marsellus+surname.=.Wallace#name.asc#100.100",
47+
"name.in.Marsellus|Mia+surname.=.Wallace#name.asc#100.100",
4848
(string)$criteria
4949
);
5050
}

0 commit comments

Comments
 (0)