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

midcom_response_json::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
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