Completed
Push — master ( dcfc04...697864 )
by Neomerx
04:30
created

Responses::getSchemaContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 21
    public function __construct(
43
        MediaTypeInterface $outputMediaType,
44
        EncoderInterface $encoder
45
    ) {
46 21
        $this->encoder         = $encoder;
47 21
        $this->outputMediaType = $outputMediaType;
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53 21
    protected function createResponse(?string $content, int $statusCode, array $headers)
54
    {
55 21
        return new JsonApiResponse($content, $statusCode, $headers);
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61 17
    protected function getEncoder(): EncoderInterface
62
    {
63 17
        return $this->encoder;
64
    }
65
66
    /**
67
     * @inheritdoc
68
     */
69 17
    protected function getMediaType(): MediaTypeInterface
70
    {
71 17
        return $this->outputMediaType;
72
    }
73
}
74