Lines
100.00%
4 / 4
Functions and Methods
100.00%
3 / 3
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Holding | 100.00% | 4 / 4 | 100.00% | 3 / 3 | 3 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| describe | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| holds | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Lorekeeper\Bot\Steps\Checks; | |
| 6 | ||
| 7 | use Generator; | |
| 8 | use Lorekeeper\Bot\Steps\Check; | |
| 9 | use Lorekeeper\Bot\Steps\StepScript; | |
| 10 | use Lorekeeper\Core\Item\ItemId; | |
| 11 | use Lorekeeper\Core\Support\Quantity; | |
| 12 | use Override; | |
| 13 | ||
| 14 | final readonly class Holding implements Check | |
| 15 | { | |
| 16 | public function __construct( | |
| 17 | public ItemId $item, | |
| 18 | public Quantity $quantity, | |
| 19 | ) {} | |
| 20 | ||
| 21 | #[Override] | |
| 22 | public function describe(): string | |
| 23 | { | |
| 24 | return "Holding item {$this->item->value} ×{$this->quantity->value}"; | |
| 25 | } | |
| 26 | ||
| 27 | #[Override] | |
| 28 | public function holds(StepScript $bot): Generator | |
| 29 | { | |
| 30 | yield from []; | |
| 31 | ||
| 32 | return $bot->me()->hero()->inventory->quantity($this->item) >= $this->quantity->value; | |
| 33 | } | |
| 34 | } |