ShapeNormalizer::getRequestShapeDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 25
ccs 24
cts 24
cp 1
crap 1
rs 9.6666
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 7
    public function getRequestShapeDefinition() : array
13
    {
14 7
        return [
15 7
            'type' => 'object',
16 7
            'required' => [
17 7
                'jsonrpc',
18 7
                'method'
19 7
            ],
20 7
            'properties' => [
21 7
                'id' => [
22 7
                    'example' => 'req_id',
23 7
                    'oneOf' => [
24 7
                        ['type' => 'string'],
25 7
                        ['type' => 'number'],
26 7
                    ],
27 7
                ],
28 7
                'jsonrpc' => [
29 7
                    'type' => 'string',
30 7
                    'example' => '2.0',
31 7
                ],
32 7
                'method' => [
33 7
                    'type' => 'string',
34 7
                ],
35 7
                'params' => [
36 7
                    'title' => 'Method parameters',
37 7
                ],
38 7
            ],
39 7
        ];
40
    }
41
42
    /**
43
     * @return array
44
     */
45 7
    public function getResponseShapeDefinition() : array
46
    {
47 7
        return [
48 7
            'type' => 'object',
49 7
            'required' => [
50 7
                'jsonrpc',
51 7
            ],
52 7
            'properties' => [
53 7
                'id' => [
54 7
                    'example' => 'req_id',
55 7
                    'oneOf' => [
56 7
                        ['type' => 'string'],
57 7
                        ['type' => 'number'],
58 7
                    ],
59 7
                ],
60 7
                'jsonrpc' => [
61 7
                    'type' => 'string',
62 7
                    'example' => '2.0',
63 7
                ],
64 7
                'result' => [
65 7
                    'title' => 'Result'
66 7
                ],
67 7
                'error' => [
68 7
                    'title' => 'Error'
69 7
                ],
70 7
            ],
71 7
        ];
72
    }
73
74
    /**
75
     * @return array
76
     */
77 28
    public function getErrorShapeDefinition() : array
78
    {
79 28
        return [
80 28
            'type' => 'object',
81 28
            'required' => [
82 28
                'code',
83 28
                'message',
84 28
            ],
85 28
            'properties' => [
86 28
                'code' => [
87 28
                    'type' => 'number',
88 28
                ],
89 28
                'message' => [
90 28
                    'type' => 'string',
91 28
                ],
92 28
            ]
93 28
        ];
94
    }
95
}
96