Passed
Pull Request — master (#12)
by Yo
02:57 queued 01:20
created

ShapeNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 46
dl 0
loc 84
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseShapeDefinition() 0 24 1
A getErrorShapeDefinition() 0 14 1
A getRequestShapeDefinition() 0 25 1
1
<?php
2
namespace Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component;
3
4
/**
5
 * Class ShapeNormalizer
6
 */
7
class ShapeNormalizer
8
{
9
    /**
10
     * @return array
11
     */
12 1
    public function getRequestShapeDefinition() : array
13
    {
14
        return [
15 1
            'type' => 'object',
16
            'required' => [
17
                'jsonrpc',
18
                'method'
19
            ],
20
            'properties' => [
21
                'id' => [
22
                    'example' => 'req_id',
23
                    'oneOf' => [
24
                        ['type' => 'string'],
25
                        ['type' => 'number'],
26
                    ],
27
                ],
28
                'jsonrpc' => [
29
                    'type' => 'string',
30
                    'example' => '2.0',
31
                ],
32
                'method' => [
33
                    'type' => 'string',
34
                ],
35
                'params' => [
36
                    'title' => 'Method parameters',
37
                ],
38
            ],
39
        ];
40
    }
41
42
    /**
43
     * @return array
44
     */
45 1
    public function getResponseShapeDefinition() : array
46
    {
47
        return [
48 1
            'type' => 'object',
49
            'required' => [
50
                'jsonrpc',
51
            ],
52
            'properties' => [
53
                'id' => [
54
                    'example' => 'req_id',
55
                    'oneOf' => [
56
                        ['type' => 'string'],
57
                        ['type' => 'number'],
58
                    ],
59
                ],
60
                'jsonrpc' => [
61
                    'type' => 'string',
62
                    'example' => '2.0',
63
                ],
64
                'result' => [
65
                    'title' => 'Result'
66
                ],
67
                'error' => [
68
                    'title' => 'Error'
69
                ],
70
            ],
71
        ];
72
    }
73
74
    /**
75
     * @return array
76
     */
77 1
    public function getErrorShapeDefinition() : array
78
    {
79
        return [
80 1
            'type' => 'object',
81
            'required' => [
82
                'code',
83
                'message',
84
            ],
85
            'properties' => [
86
                'code' => [
87
                    'type' => 'number',
88
                ],
89
                'message' => [
90
                    'type' => 'string',
91
                ],
92
            ]
93
        ];
94
    }
95
}
96