Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
LoadInventoryScript
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 start
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 handles
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace AqwSocketClient\Scripts;
6
7use AqwSocketClient\Commands\LoadPlayerInventoryCommand;
8use AqwSocketClient\Events\PlayerInventoryLoadedEvent;
9use AqwSocketClient\Interfaces\CommandInterface;
10use AqwSocketClient\Interfaces\EventInterface;
11use AqwSocketClient\Objects\Identifiers\AreaIdentifier;
12use AqwSocketClient\Objects\Identifiers\SocketIdentifier;
13use Override;
14use Psl\Type;
15
16final 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}