Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
JoinBattleonScript
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
5
100.00% covered (success)
100.00%
1 / 1
 start
100.00% covered (success)
100.00%
1 / 1
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%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace AqwSocketClient\Scripts;
6
7use AqwSocketClient\Commands\JoinInitialAreaCommand;
8use AqwSocketClient\Events\AreaJoinedEvent;
9use AqwSocketClient\Interfaces\CommandInterface;
10use AqwSocketClient\Interfaces\EventInterface;
11use Override;
12
13final class JoinBattleonScript extends AbstractScript
14{
15    #[Override]
16    public function start(ClientContext $context): ?CommandInterface
17    {
18        return new JoinInitialAreaCommand();
19    }
20
21    #[Override]
22    public function handles(): array
23    {
24        return [AreaJoinedEvent::class];
25    }
26
27    #[Override]
28    public function handle(EventInterface $event, ClientContext $context): ?CommandInterface
29    {
30        if ($event instanceof AreaJoinedEvent && $event->area->name->value === 'battleon') {
31            $context->set('area_id', $event->area->identifier);
32            $this->success();
33        }
34
35        return null;
36    }
37}