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

Action   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 34
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A dispatch() 0 9 1
init() 0 1 ?
performChecks() 0 1 ?
performAction() 0 1 ?
performCallBack() 0 1 ?
formatResponse() 0 1 ?
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