Completed
Push — develop ( e92646...02469b )
by Henry
08:15
created

RequestHandler::setOptions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the Divergence package.
4
 *
5
 * (c) Henry Paradiz <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Divergence\Controllers;
11
12
use Divergence\App;
13
use Divergence\Responders\Response;
14
use Psr\Http\Message\ResponseInterface;
15
use Psr\Http\Message\ServerRequestInterface;
16
use Psr\Http\Server\RequestHandlerInterface;
17
18
abstract class RequestHandler implements RequestHandlerInterface
19
{
20
    public string $responseBuilder;
21
22
    public function peekPath()
23
    {
24
        return App::$App->Path->peekPath();
25
    }
26
27
    public function shiftPath()
28
    {
29
        return App::$App->Path->shiftPath();
30
    }
31
32
    public function unshiftPath($string)
33
    {
34
        return App::$App->Path->unshiftPath($string);
35
    }
36
37
    public function respond($responseID, $responseData = []): ResponseInterface
38
    {
39
        $className = $this->responseBuilder;
40
        return new Response(new $className($responseID, $responseData));
41
    }
42
43
    abstract public function handle(ServerRequestInterface $request): ResponseInterface;
44
}
45