Passed
Push — master ( 7131c3...da602a )
by Andreas
30:18
created

midcom_response_json   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 16
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendContent() 0 4 1
A __construct() 0 5 1
1
<?php
2
/**
3
 * @package midcom
4
 * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/
5
 * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 */
8
9
/**
10
 * Wrapper for HTTP responses
11
 *
12
 * @package midcom
13
 */
14
class midcom_response_json extends midcom_response
15
{
16 11
    public function __construct(array $data = [])
17
    {
18 11
        parent::__construct();
19 11
        $this->_data = $data;
20 11
        $this->headers->set('Content-Type', 'application/json; charset=' . $this->encoding);
21
    }
22
23
    /**
24
     * Sends the response to the client and shuts down the environment
25
     */
26
    public function sendContent()
27
    {
28
        $exporter = new midcom_helper_exporter_json();
29
        echo $exporter->array2data($this->_data);
30
    }
31
}
32