Completed
Push — master ( f9ded0...b13d5b )
by John
02:58 queued 01:00
created

JSONResponse::getMIMEType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace LunixREST\APIResponse;
3
4
use Psr\Http\Message\StreamInterface;
5
6
/**
7
 * Class JSONResponse
8
 * @package LunixREST\APIResponse
9
 */
10
class JSONResponse implements APIResponse
11
{
12
    /**
13
     * @var null|object|array
14
     */
15
    public $data;
16
17 6
    public function __construct($data)
18
    {
19 6
        $this->data = $data;
20 6
    }
21
22
    /**
23
     * @return StreamInterface
24
     */
25 1
    public function getAsDataStream(): StreamInterface
26
    {
27 1
        return \GuzzleHttp\Psr7\Stream_for(json_encode($this->data));
28
    }
29
30 1
    public function getMIMEType(): string
31
    {
32 1
        return 'application/json';
33
    }
34
35
    /**
36
     * @return null|object|array
37
     */
38 1
    public function getResponseData()
39
    {
40 1
        return $this->data;
41
    }
42
}
43