Lines 100.00% 5 / 5
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 4 / 4 100.00% 1 / 1 3
 costs 100.00% 1 / 1 100.00% 1 / 1 1
13final readonly class MergeShop extends Shop
14{
15    /**
16     * @param Inventory<Item> $inventory
17     * @param array<positive-int, list<MergeCost>> $costs
18     *
19     * @throws InvalidArgumentException
20     */
21    public function __construct(
22        ShopId $id,
23        ShopName $name,
24        public Inventory $inventory,
25        private array $costs,
26    ) {
27        parent::__construct($id, $name);
28
29        foreach ($inventory as $item) {
30            if (($costs[$item->id->value] ?? []) === []) {
31                throw new InvalidArgumentException("Merging {$item->name} costs nothing.");
32            }
33        }
34    }
35
36    /** @return Option\Option<list<MergeCost>> */
37    public function costs(ItemId $id): Option\Option
38    {
39        return Option\from_nullable($this->costs[$id->value] ?? null);
40    }
41}