1 | <?php |
||
15 | class ProductRepository implements ProductRepositoryInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var StorageInterface |
||
19 | */ |
||
20 | private $productStorage; |
||
21 | /** |
||
22 | * @var ProductMapper |
||
23 | */ |
||
24 | private $productMapper; |
||
25 | |||
26 | /** |
||
27 | * Creates a new ProductRepository instance. |
||
28 | * |
||
29 | * @param StorageInterface $productStorage A product storage for reading and writing product data |
||
30 | * @param ProductMapper $productMapper A product mapper for mapping unstructured data to Product models and |
||
31 | * vice versa |
||
32 | */ |
||
33 | 3 | public function __construct(StorageInterface $productStorage, ProductMapper $productMapper) |
|
38 | |||
39 | /** |
||
40 | * Get all products |
||
41 | * |
||
42 | * @return Product[] |
||
43 | * |
||
44 | * @throws RepositoryException If fetching the products failed |
||
45 | */ |
||
46 | 3 | public function getProducts() |
|
65 | |||
66 | public function getById(string $id) |
||
70 | |||
71 | public function add(Product $product) |
||
75 | |||
76 | public function remove(Product $product) |
||
80 | } |