HateoasResponseGenerator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 2
1
<?php
2
namespace Phrest\API;
3
4
class HateoasResponseGenerator
5
{
6
    private $hateoas;
7
8
    public function __construct(\Hateoas\Hateoas $hateoas)
9
    {
10
        $this->hateoas = $hateoas;
11
    }
12
13
    public function generate($model, int $httpStatusCode = 200, array $headers = []) : \Psr\Http\Message\ResponseInterface {
14
        return new \Zend\Diactoros\Response\TextResponse(
15
            $this->hateoas->serialize($model, 'json'),
16
            $httpStatusCode,
17
            $headers + ['Content-Type' => 'application/json']
18
        );
19
    }
20
}