Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| LoadInventoryScript | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| start | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| handles | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AqwSocketClient\Scripts; |
| 6 | |
| 7 | use AqwSocketClient\Commands\LoadPlayerInventoryCommand; |
| 8 | use AqwSocketClient\Events\PlayerInventoryLoadedEvent; |
| 9 | use AqwSocketClient\Interfaces\CommandInterface; |
| 10 | use AqwSocketClient\Interfaces\EventInterface; |
| 11 | use AqwSocketClient\Objects\Identifiers\AreaIdentifier; |
| 12 | use AqwSocketClient\Objects\Identifiers\SocketIdentifier; |
| 13 | use Override; |
| 14 | use Psl\Type; |
| 15 | |
| 16 | final class LoadInventoryScript extends AbstractScript |
| 17 | { |
| 18 | #[Override] |
| 19 | public function start(ClientContext $context): ?CommandInterface |
| 20 | { |
| 21 | $socketId = Type\instance_of(SocketIdentifier::class)->assert($context->get('socket_id')); |
| 22 | $areaId = Type\instance_of(AreaIdentifier::class)->assert($context->get('area_id')); |
| 23 | |
| 24 | return new LoadPlayerInventoryCommand($areaId, $socketId); |
| 25 | } |
| 26 | |
| 27 | #[Override] |
| 28 | public function handles(): array |
| 29 | { |
| 30 | return [PlayerInventoryLoadedEvent::class]; |
| 31 | } |
| 32 | |
| 33 | #[Override] |
| 34 | public function handle(EventInterface $event, ClientContext $context): ?CommandInterface |
| 35 | { |
| 36 | if ($event instanceof PlayerInventoryLoadedEvent) { |
| 37 | $this->success(); |
| 38 | } |
| 39 | |
| 40 | return null; |
| 41 | } |
| 42 | } |