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

JSONResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAsString() 0 3 1
A getMIMEType() 0 3 1
A getResponseData() 0 3 1
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