ResultDocNormalizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 32
ccs 13
cts 13
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A normalize() 0 14 2
1
<?php
2
namespace Yoanm\JsonRpcHttpServerSwaggerDoc\App\Normalizer\Component;
3
4
use Yoanm\JsonRpcHttpServerSwaggerDoc\App\Resolver\DefinitionRefResolver;
5
use Yoanm\JsonRpcServerDoc\Domain\Model\MethodDoc;
6
7
/**
8
 * Class ResultDocNormalizer
9
 */
10
class ResultDocNormalizer
11
{
12
    /** @var DefinitionRefResolver */
13
    private $definitionRefResolver;
14
15
    /**
16
     * @param DefinitionRefResolver $definitionRefResolver
17
     */
18 2
    public function __construct(DefinitionRefResolver $definitionRefResolver)
19
    {
20 2
        $this->definitionRefResolver = $definitionRefResolver;
21
    }
22
23
    /**
24
     * @param MethodDoc $method
25
     *
26
     * @return array
27
     */
28 2
    public function normalize(MethodDoc $method) : array
29
    {
30 2
        if (null !== $method->getResultDoc()) {
31 1
            return [
32 1
                '$ref' => $this->definitionRefResolver->getDefinitionRef(
33 1
                    $this->definitionRefResolver->getMethodDefinitionId(
34 1
                        $method,
35 1
                        DefinitionRefResolver::METHOD_RESULT_DEFINITION_TYPE
36 1
                    )
37 1
                )
38 1
            ];
39
        }
40
41 1
        return ['description' => 'Method result'];
42
    }
43
}
44