Skip to content

Commit 66f37e6

Browse files
author
janvt
authored
Merge pull request #19 from Bl00D4NGEL/pass-items-to-repository
Enable InMemory repository to accept items in constructor
2 parents 8e000ea + 687479e commit 66f37e6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Infrastructure/InMemory/Repository.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@
1717
*/
1818
abstract class Repository implements RepositoryInterface
1919
{
20-
/**
21-
* @var T[]
22-
*/
23-
protected array $items = [];
24-
2520
/**
2621
* @param class-string<T> $itemType
22+
* @param T[] $items
2723
*/
2824
public function __construct(
2925
private string $itemType,
26+
protected array $items = []
3027
) {
3128
Assert::that($this->itemType)->classExists();
29+
Assert::thatAll($this->items)->isInstanceOf($this->itemType);
3230
}
3331

3432
/**

0 commit comments

Comments
 (0)