Issues (51)

examples/Handlers/SimpleIntentRequestHandler.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
use MaxBeckers\AmazonAlexa\Helper\ResponseHelper;
6
use MaxBeckers\AmazonAlexa\Request\Request;
7
use MaxBeckers\AmazonAlexa\Request\Request\Standard\IntentRequest;
8
use MaxBeckers\AmazonAlexa\RequestHandler\AbstractRequestHandler;
9
use MaxBeckers\AmazonAlexa\Response\Response;
10
11
/**
12
 * Just a simple example request handler.
13
 */
14
class SimpleIntentRequestHandler extends AbstractRequestHandler
15
{
16
    public function __construct(
17
        private readonly ResponseHelper $responseHelper
18
    ) {
19
        parent::__construct();
20
        $this->supportedApplicationIds = ['my_amazon_skill_id'];
21
    }
22
23
    public function supportsRequest(Request $request): bool
24
    {
25
        // support all intent requests, should not be done.
26
        return $request->request instanceof IntentRequest;
27
    }
28
29
    public function handleRequest(Request $request): Response
30
    {
31
        return $this->responseHelper->respond('Success :)');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->responseHe...->respond('Success :)') could return the type null which is incompatible with the type-hinted return MaxBeckers\AmazonAlexa\Response\Response. Consider adding an additional type-check to rule them out.
Loading history...
32
    }
33
}