Skip to content

Commit 3f8a19f

Browse files
authored
Merge pull request #8 from eiling-io/batteryincluded-php-sdk-7
#7 - addRangeFilter method to SearchStruct
2 parents 2bba474 + 40f45b6 commit 3f8a19f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Shop/BrowseSearchStruct.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public function addFilter(string $key, string $value): void
4343
$this->filters[$key][] = $value;
4444
}
4545

46+
public function addRangeFilter(string $key, string $from, string $till): void
47+
{
48+
$this->filters[$key]['from'] = $from;
49+
$this->filters[$key]['till'] = $till;
50+
}
51+
4652
public function addFilters(array $filters): void
4753
{
4854
foreach ($filters as $key => $values) {

tests/Shop/BrowseSearchStructTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ public function testAddAndGetFilters()
3434
$struct->addFilter('color', 'red');
3535
$struct->addFilter('color', 'blue');
3636
$struct->addFilter('size', 'L');
37+
$struct->addRangeFilter('price', '10', '50');
3738
$expected = [
3839
'color' => ['red', 'blue'],
3940
'size' => ['L'],
41+
'price' => ['from' => '10', 'till' => '50'],
4042
];
4143
$this->assertSame($expected, $struct->getFilters());
4244
}

0 commit comments

Comments
 (0)