ShapeNormalizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseShapeDefinition() 0 16 1
A getErrorShapeDefinition() 0 8 1
A getRequestShapeDefinition() 0 16 1
1
<?php
2
namespace Yoanm\JsonRpcHttpServerSwaggerDoc\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' => ['jsonrpc', 'method'],
17 7
            'properties' => [
18 7
                'id' => [
19 7
                    'example' => 'req_id',
20 7
                    'type' => 'string',
21 7
                ],
22 7
                'jsonrpc' => [
23 7
                    'type' => 'string',
24 7
                    'example' => '2.0',
25 7
                ],
26 7
                'method' => ['type' => 'string'],
27 7
                'params' => ['title' => 'Method parameters'],
28 7
            ],
29 7
        ];
30
    }
31
32
    /**
33
     * @return array
34
     */
35 7
    public function getResponseShapeDefinition() : array
36
    {
37 7
        return [
38 7
            'type' => 'object',
39 7
            'required' => ['jsonrpc'],
40 7
            'properties' => [
41 7
                'id' => [
42 7
                    'type' => 'string',
43 7
                    'example' => 'req_id',
44 7
                ],
45 7
                'jsonrpc' => [
46 7
                    'type' => 'string',
47 7
                    'example' => '2.0',
48 7
                ],
49 7
                'result' => ['title' => 'Result'],
50 7
                'error' => ['title' => 'Error'],
51 7
            ],
52 7
        ];
53
    }
54
55
    /**
56
     * @return array
57
     */
58 37
    public function getErrorShapeDefinition() : array
59
    {
60 37
        return [
61 37
            'type' => 'object',
62 37
            'required' => ['code', 'message'],
63 37
            'properties' => [
64 37
                'code' => ['type' => 'number'],
65 37
                'message' => ['type' => 'string'],
66 37
            ]
67 37
        ];
68
    }
69
}
70