Passed
Pull Request — release/1.0.0 (#5)
by Yo
01:23
created

ShapeNormalizer::getResponseShapeDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 16
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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 1
    public function getRequestShapeDefinition()
13
    {
14
        return [
15 1
            'type' => 'object',
16
            'required' => ['jsonrpc', 'method'],
17
            'properties' => [
18
                'id' => [
19
                    'example' => 'req_id',
20
                    'type' => 'string',
21
                ],
22
                'jsonrpc' => [
23
                    'type' => 'string',
24
                    'example' => '2.0',
25
                ],
26
                'method' => ['type' => 'string'],
27
                'params' => ['title' => 'Method parameters'],
28
            ],
29
        ];
30
    }
31
32
    /**
33
     * @return array
34
     */
35 1
    public function getResponseShapeDefinition()
36
    {
37
        return [
38 1
            'type' => 'object',
39
            'required' => ['jsonrpc'],
40
            'properties' => [
41
                'id' => [
42
                    'type' => 'string',
43
                    'example' => 'req_id',
44
                ],
45
                'jsonrpc' => [
46
                    'type' => 'string',
47
                    'example' => '2.0',
48
                ],
49
                'result' => ['title' => 'Result'],
50
                'error' => ['title' => 'Error'],
51
            ],
52
        ];
53
    }
54
55
    /**
56
     * @return array
57
     */
58 1
    public function getErrorShapeDefinition()
59
    {
60
        return [
61 1
            'type' => 'object',
62
            'required' => ['code', 'message'],
63
            'properties' => [
64
                'code' => ['type' => 'number'],
65
                'message' => ['type' => 'string'],
66
            ]
67
        ];
68
    }
69
}
70