Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2.003 |
Changes | 0 |
1 | <?php |
||
28 | 5 | public function sendJsonObjectResponse($object, $statusCode = 200) |
|
29 | { |
||
30 | 5 | if (!is_object($object)) { |
|
31 | throw new InvalidArgumentException('You must pass an object.'); |
||
32 | } |
||
33 | 5 | $this->disableLayout(); |
|
34 | 5 | $this->disableView(); |
|
35 | 5 | $this->setHeader('Cache-Control', 'no-cache, must-revalidate'); |
|
36 | 5 | $this->setHeader('Expires','Mon, 26 Jul 1997 05:00:00 GMT'); |
|
37 | 5 | $this->setHeader('Content-Type','application/json'); |
|
38 | 5 | $json = $this->serializer->serialize($object, 'json'); |
|
39 | 5 | $this->setBody($json); |
|
40 | 5 | $this->setStatusCode($statusCode); |
|
41 | 5 | } |
|
53 | } |