Completed
Branch FET/11183/improvements-to-pue-... (232f50)
by
unknown
43:46 queued 26:36
created

Response   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 130
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 130
rs 10
c 0
b 0
f 0
wmc 12
lcom 4
cbo 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setNotice() 0 4 1
A getNotice() 0 4 2
A getNotices() 0 4 1
A addOutput() 0 4 2
A getOutput() 0 4 1
A requestTerminated() 0 4 1
A terminateRequest() 0 4 1
A pluginDeactivated() 0 4 1
A deactivatePlugin() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\services\request;
4
5
defined('EVENT_ESPRESSO_VERSION') || exit;
6
7
8
9
/**
10
 * class Response
11
 * Passes output, notices, and request termination status between Middleware classes
12
 *
13
 * @package         Event Espresso
14
 * @subpackage      /core/
15
 * @author          Brent Christensen
16
 * ------------------------------------------------------------------------
17
 */
18
class Response implements ResponseInterface
19
{
20
21
    /**
22
     * @var array $notice
23
     */
24
    protected $notice = array();
25
26
    /**
27
     * rendered output to be returned to WP
28
     *
29
     * @var string $output
30
     */
31
    protected $output = '';
32
33
    /**
34
     * @var bool
35
     */
36
    protected $request_terminated = false;
37
38
    /**
39
     * @var bool $deactivate_plugin
40
     */
41
    protected $deactivate_plugin = false;
42
43
44
    /**
45
     * EE_Response constructor.
46
     */
47
    public function __construct()
48
    {
49
        $this->terminateRequest(false);
50
    }
51
52
53
54
    /**
55
     * @param $key
56
     * @param $value
57
     * @return    void
58
     */
59
    public function setNotice($key, $value)
60
    {
61
        $this->notice[ $key ] = $value;
62
    }
63
64
65
66
    /**
67
     * @param $key
68
     * @return    mixed
69
     */
70
    public function getNotice($key)
71
    {
72
        return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
73
    }
74
75
76
77
    /**
78
     * @return array
79
     */
80
    public function getNotices()
81
    {
82
        return $this->notice;
83
    }
84
85
86
87
    /**
88
     * @param string $string
89
     * @param bool   $append
90
     */
91
    public function addOutput($string, $append = true)
92
    {
93
        $this->output = $append ? $this->output . $string : $string . $this->output;
94
    }
95
96
97
98
    /**
99
     * @return string
100
     */
101
    public function getOutput()
102
    {
103
        return $this->output;
104
    }
105
106
107
108
    /**
109
     * @return boolean
110
     */
111
    public function requestTerminated()
112
    {
113
        return $this->request_terminated;
114
    }
115
116
117
118
    /**
119
     * @param boolean $request_terminated
120
     */
121
    public function terminateRequest($request_terminated = true)
122
    {
123
        $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
124
    }
125
126
127
128
    /**
129
     * @return boolean
130
     */
131
    public function pluginDeactivated()
132
    {
133
        return $this->deactivate_plugin;
134
    }
135
136
137
138
    /**
139
     * sets $deactivate_plugin to true
140
     */
141
    public function deactivatePlugin()
142
    {
143
        $this->deactivate_plugin = true;
144
    }
145
146
147
}
148
// End of file EE_Response.core.php
149
// Location: /core/EE_Response.core.php
150