Completed
Push — master ( 3b1a80...1321d9 )
by Vincenzo
03:50
created

Action::dispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
4
namespace App\Lib\Slime\RestAction;
5
6
7
use App\Lib\Slime\Interfaces\UseCase\IAction;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
abstract class Action implements IAction
12
{
13
    protected $args;
14
    protected $request;
15
    protected $response;
16
17
    public function __construct(
18
        RequestInterface $request = null,
19
        ResponseInterface $response = null,
20
        array $args = []
21
    )
22
    {
23
        $this->args = $args;
24
        $this->request = $request;
25
        $this->response = $response;
26
    }
27
28
    public function dispatch()
29
    {
30
        $this->init();
31
        $this->performChecks();
32
        $this->performAction();
33
        $this->performCallBack();
34
        $this->formatResponse();
35
        return $this->response;
36
    }
37
38
    protected abstract function init();
39
    protected abstract function performChecks();
40
    protected abstract function performAction();
41
    protected abstract function performCallBack();
42
    protected abstract function formatResponse();
43
44
}
45