Abstraction::setBootstrap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace FMUP\ErrorHandler\Plugin;
3
4
use FMUP\Bootstrap;
5
use FMUP\Exception;
6
use FMUP\Request;
7
use FMUP\Response;
8
use FMUP\Sapi;
9
10
abstract class Abstraction
11
{
12
    private $response;
13
    private $request;
14
    private $bootstrap;
15
16
    /**
17
     * @var \Exception
18
     */
19
    private $exception;
20
21
    /**
22
     * @param Bootstrap $bootstrap
23
     * @return $this
24
     */
25 5
    public function setBootstrap(Bootstrap $bootstrap)
26
    {
27 5
        $this->bootstrap = $bootstrap;
28 5
        return $this;
29
    }
30
31
    /**
32
     * @return Bootstrap
33
     * @throws Exception
34
     */
35 4
    public function getBootstrap()
36
    {
37 4
        if (!$this->bootstrap) {
38 1
            throw new Exception('Unable to access bootstrap. Not set');
39
        }
40 3
        return $this->bootstrap;
41
    }
42
43
    /**
44
     * @param Response $response
45
     * @return $this
46
     */
47 3
    public function setResponse(Response $response)
48
    {
49 3
        $this->response = $response;
50 3
        return $this;
51
    }
52
53
    /**
54
     * @return Response
55
     * @throws Exception
56
     */
57 3
    public function getResponse()
58
    {
59 3
        if (!$this->response) {
60 1
            throw new Exception('Unable to access response. Not set');
61
        }
62 2
        return $this->response;
63
    }
64
65
    /**
66
     * @param Request $request
67
     * @return $this
68
     */
69 3
    public function setRequest(Request $request)
70
    {
71 3
        $this->request = $request;
72 3
        return $this;
73
    }
74
75
    /**
76
     * @return Request
77
     * @throws Exception
78
     */
79 2
    public function getRequest()
80
    {
81 2
        if (!$this->request) {
82 1
            throw new Exception('Unable to access request. Not set');
83
        }
84 1
        return $this->request;
85
    }
86
87 5
    public function setException(\Exception $e)
88
    {
89 5
        $this->exception = $e;
90 5
        return $this;
91
    }
92
93 3
    public function getException()
94
    {
95 3
        return $this->exception;
96
    }
97
98
    /**
99
     * @return $this
100
     */
101
    abstract public function handle();
102
103
    /**
104
     * @return bool
105
     */
106
    abstract public function canHandle();
107
}
108