22
33namespace wcf \action ;
44
5- use BadMethodCallException ;
65use Laminas \Diactoros \Response \HtmlResponse ;
76use Laminas \Diactoros \Response \JsonResponse ;
8- use LogicException ;
9- use OutOfBoundsException ;
10- use Override ;
117use Psr \Http \Message \ResponseInterface ;
128use Psr \Http \Message \ServerRequestInterface ;
139use Psr \Http \Server \RequestHandlerInterface ;
14- use Throwable ;
15- use UnexpectedValueException ;
1610use wcf \data \discord \bot \DiscordBotList ;
1711use wcf \data \discord \interaction \log \DiscordInteractionLogAction ;
1812use wcf \system \discord \DiscordApi ;
2115
2216abstract class AbstractDiscordInteractionAction implements RequestHandlerInterface, IDiscordInteractionAction
2317{
24- #[Override]
18+ #[\ Override]
2519 public function handle (ServerRequestInterface $ request ): ResponseInterface
2620 {
2721 if ($ request ->getMethod () === 'POST ' ) {
@@ -39,18 +33,18 @@ public function handle(ServerRequestInterface $request): ResponseInterface
3933 }
4034
4135 if ($ body === '' ) {
42- throw new BadMethodCallException ('body is empty ' );
36+ throw new \ BadMethodCallException ('body is empty ' );
4337 }
4438 $ data = [];
4539 try {
4640 $ data = JSON ::decode ($ body , true );
47- } catch (Throwable ) {
48- throw new BadMethodCallException ('body is not valid json ' );
41+ } catch (\ Throwable ) {
42+ throw new \ BadMethodCallException ('body is not valid json ' );
4943 }
5044
5145 $ publicKeys = $ this ->getPublicKeys ();
5246 if ($ publicKeys === []) {
53- throw new UnexpectedValueException ('public key is empty ' );
47+ throw new \ UnexpectedValueException ('public key is empty ' );
5448 }
5549
5650 $ validRequest = false ;
@@ -61,11 +55,11 @@ public function handle(ServerRequestInterface $request): ResponseInterface
6155 }
6256 }
6357 if (!$ validRequest ) {
64- throw new OutOfBoundsException ('invalid request signature ' );
58+ throw new \ OutOfBoundsException ('invalid request signature ' );
6559 }
6660
6761 if (!isset ($ data ['type ' ])) {
68- throw new BadMethodCallException ('type is empty ' );
62+ throw new \ BadMethodCallException ('type is empty ' );
6963 }
7064
7165 switch ($ data ['type ' ]) {
@@ -80,17 +74,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface
8074 case DiscordApi::DISCORD_MODAL_SUBMIT :
8175 return $ this ->handleModalCommand ($ data );
8276 default :
83- throw new BadMethodCallException ('unknown component ' );
77+ throw new \ BadMethodCallException ('unknown component ' );
8478 }
85- } catch (BadMethodCallException $ e ) {
79+ } catch (\ BadMethodCallException $ e ) {
8680 return new HtmlResponse ($ e ->getMessage (), 400 );
87- } catch (OutOfBoundsException $ e ) {
81+ } catch (\ OutOfBoundsException $ e ) {
8882 return new HtmlResponse ($ e ->getMessage (), 401 );
89- } catch (UnexpectedValueException $ e ) {
83+ } catch (\ UnexpectedValueException $ e ) {
9084 return new HtmlResponse ($ e ->getMessage (), 501 );
9185 }
9286 } else {
93- throw new LogicException ('Unreachable ' );
87+ throw new \ LogicException ('Unreachable ' );
9488 }
9589 }
9690
@@ -102,7 +96,7 @@ private function sendPong(): JsonResponse
10296 return new JsonResponse ((new PingInteractionCallback ())->getInteractionResponse ());
10397 }
10498
105- #[Override]
99+ #[\ Override]
106100 public function getPublicKeys (): array
107101 {
108102 $ publicKeys = [];
0 commit comments