HateoasResponseGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 14
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 5 1
A __construct() 0 3 1
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
}