Lines
100.00%
12 / 12
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| from | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 4 | ||
| summary | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 1 | ||
| 18 | final readonly class QuestItemsIncreasedEvent extends InventoryUpdatedEvent | |
| 19 | { | |
| 20 | /** @param non-empty-list<ItemIncrease> $items */ | |
| 21 | public function __construct( | |
| 22 | public array $items, | |
| 23 | ) {} | |
| 24 | ||
| 25 | /** @return Option\Option<static> */ | |
| 26 | #[Override] | |
| 27 | public static function from(Message $message): Option\Option | |
| 28 | { | |
| 29 | $items = []; | |
| 30 | foreach (ItemArrivals::of($message, static::class) ?? [] as [$kind, $entry]) { | |
| 31 | if ($kind !== ItemArrival::QuestItemIncreased) { | |
| 32 | continue; | |
| 33 | } | |
| 34 | ||
| 35 | $items[] = new ItemIncrease(new ItemId($entry['ItemID']), new Quantity($entry['iQty'])); | |
| 36 | } | |
| 37 | ||
| 38 | return $items === [] ? Option\none() : Option\some(new static($items)); | |
| 39 | } | |
| 40 | ||
| 41 | #[Override] | |
| 42 | public function summary(): string | |
| 43 | { | |
| 44 | return 'Got for now ' | |
| 45 | . implode(', ', array_map( | |
| 46 | static fn(ItemIncrease $added): string => "{$added->quantity->value} more of item {$added->item->value}", | |
| 47 | $this->items, | |
| 48 | )); | |
| 49 | } | |
| 50 | } |