Passed
Push — master ( 0ad48d...150bba )
by Yo
55s queued 11s
created

RawDocProvider::getDoc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
namespace Yoanm\SymfonyJsonRpcHttpServerDoc\Provider;
3
4
use Yoanm\JsonRpcServerDoc\Infra\Normalizer\HttpServerDocNormalizer;
5
use Yoanm\SymfonyJsonRpcHttpServerDoc\Creator\HttpServerDocCreator;
6
7
/**
8
 * Class RawDocProvider
9
 */
10
class RawDocProvider implements DocProviderInterface
11
{
12
    /** @var HttpServerDocCreator */
13
    private $httpServerDocCreator;
14
    /** @var HttpServerDocNormalizer */
15
    private $serverDocNormalizer;
16
17
    const SUPPORTED_FILENAME = 'raw.json';
18
19
    /**
20
     * @param HttpServerDocCreator    $HttpServerDocCreator
21
     * @param HttpServerDocNormalizer $serverDocNormalizer
22
     */
23 2
    public function __construct(
24
        HttpServerDocCreator $HttpServerDocCreator,
25
        HttpServerDocNormalizer $serverDocNormalizer
26
    ) {
27 2
        $this->httpServerDocCreator = $HttpServerDocCreator;
28 2
        $this->serverDocNormalizer = $serverDocNormalizer;
29 2
    }
30
31
    /**
32
     * @param string|null $host
33
     *
34
     * @return array
35
     */
36 1
    public function getDoc($host = null) : array
37
    {
38 1
        return $this->serverDocNormalizer->normalize(
39 1
            $this->httpServerDocCreator->create($host)
40
        );
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function supports($filename, $host = null) : bool
47
    {
48 1
        return self::SUPPORTED_FILENAME === $filename;
49
    }
50
}
51