Responses   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 48
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A createResponse() 0 4 1
A getEncoder() 0 4 1
A getMediaType() 0 4 1
1
<?php declare (strict_types = 1);
2
3
namespace Limoncello\Flute\Http;
4
5
/**
6
 * Copyright 2015-2019 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Neomerx\JsonApi\Contracts\Encoder\EncoderInterface;
22
use Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface;
23
use Neomerx\JsonApi\Http\BaseResponses;
24
25
/**
26
 * @package Limoncello\Flute
27
 */
28
class Responses extends BaseResponses
29
{
30
    /**
31
     * @var EncoderInterface
32
     */
33
    private $encoder;
34
35
    /**
36
     * @var MediaTypeInterface
37
     */
38
    private $outputMediaType;
39
40
    /**
41
     * @param MediaTypeInterface $outputMediaType
42
     * @param EncoderInterface   $encoder
43
     */
44 21
    public function __construct(
45
        MediaTypeInterface $outputMediaType,
46
        EncoderInterface $encoder
47
    ) {
48 21
        $this->encoder         = $encoder;
49 21
        $this->outputMediaType = $outputMediaType;
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55 21
    protected function createResponse(?string $content, int $statusCode, array $headers)
56
    {
57 21
        return new JsonApiResponse($content, $statusCode, $headers);
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63 17
    protected function getEncoder(): EncoderInterface
64
    {
65 17
        return $this->encoder;
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71 17
    protected function getMediaType(): MediaTypeInterface
72
    {
73 17
        return $this->outputMediaType;
74
    }
75
}
76