Skip to content

Commit e643e1b

Browse files
authored
Add by_slugs parameter (#81)
1 parent 6bbe80d commit e643e1b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Request/StoriesRequest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function __construct(
6161
public ?FirstPublishedAtLt $firstPublishedAtLt = null,
6262
public ?UpdatedAtGt $updatedAtGt = null,
6363
public ?UpdatedAtLt $updatedAtLt = null,
64+
public SlugCollection $bySlugs = new SlugCollection(),
6465
) {
6566
Assert::stringNotEmpty($language);
6667
Assert::lessThanEq($this->pagination->perPage, self::MAX_PER_PAGE);
@@ -168,6 +169,10 @@ public function toArray(): array
168169
$array['updated_at_lt'] = $this->updatedAtLt->toString();
169170
}
170171

172+
if ($this->bySlugs->count() > 0) {
173+
$array['by_slugs'] = $this->bySlugs->toString();
174+
}
175+
171176
return $array;
172177
}
173178
}

tests/Unit/Request/StoriesRequestTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,22 @@ public function toArrayWithUpdatedAtLt(): void
348348
'updated_at_lt' => $expectedDate,
349349
], $request->toArray());
350350
}
351+
352+
#[Test]
353+
public function toArrayBySlugs(): void
354+
{
355+
$request = new StoriesRequest(
356+
bySlugs: new SlugCollection([
357+
new Slug('path/*'),
358+
new Slug('another-path/*'),
359+
]),
360+
);
361+
362+
self::assertSame([
363+
'language' => 'default',
364+
'page' => 1,
365+
'per_page' => 25,
366+
'by_slugs' => 'path/*,another-path/*',
367+
], $request->toArray());
368+
}
351369
}

0 commit comments

Comments
 (0)