Completed
Push — develop ( dcfc04...3d10a6 )
by Neomerx
04:33
created

Responses   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

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