Completed
Push — master ( 093ab2...84b6a3 )
by John
01:55
created

JSONResponse::getAsString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace LunixREST\Response;
3
4
/**
5
 * Class JSONResponse
6
 * @package LunixREST\Response
7
 */
8
class JSONResponse implements Response {
9
    /**
10
     * @var ResponseData
11
     */
12
    public $data;
13
14
    public function __construct(ResponseData $data) {
15
        $this->data = $data;
16
    }
17
18
    /**
19
     * @return string
20
     */
21
    public function getAsString(): string {
22
        return json_encode($this->data->getAsAssociativeArray());
23
    }
24
25
    public function getMIMEType(): string {
26
        return 'application/json';
27
    }
28
29
    /**
30
     * @return ResponseData
31
     */
32
    public function getResponseData(): ResponseData {
33
        return $this->data;
34
    }
35
}
36