Completed
Push — master ( c09155...5d7ab2 )
by thomas
02:01
created

ValidatorFactory::callResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Trezor\Bridge\Schema;
6
7
class ValidatorFactory
8
{
9
    const VERSION_RESPONSE_VALIDATOR = <<<EOJSON
10
{
11
    "title": "VersionResponse",
12
    "type": "object",
13
    "properties": {
14
        "version": {
15
            "type": "string"
16
        }
17
    },
18
    "required": ["version"]
19
}
20
EOJSON;
21
22
    const LIST_DEVICES_RESPONSE_VALIDATOR = <<<EOJSON
23
{
24
  "title": "ListDevicesResponse",
25
  "type": "array",
26
  "items": {
27
    "type": "object",
28
    "properties": {
29
      "path": {
30
        "type": "string"
31
      },
32
      "vendor": {
33
        "type": "number"
34
      },
35
      "product": {
36
        "type": "number"
37
      },
38
      "session": {
39
        "type": ["string", "null"]
40
      }
41
    },
42
    "required": [
43
      "path", "session"
44
    ]
45
  }
46
}
47
EOJSON;
48
49
    const ACQUIRE_RESPONSE_VALIDATOR = <<<EOJSON
50
{
51
  "title": "AcquireResponse",
52
  "type": "object",  
53
  "properties": {
54
    "session": {
55
      "type": "string"
56
    }
57
  },
58
  "required": [
59
    "session"
60
  ]
61
}
62
EOJSON;
63
64
    const RELEASE_RESPONSE_VALIDATOR = <<<EOJSON
65
{
66
  "title": "ReleaseResponse",
67
  "type": "object",  
68
  "properties": {},
69
  "required": []
70
}
71
EOJSON;
72
73 5
    public function versionResponse(): \stdClass
74
    {
75 5
        return json_decode(self::VERSION_RESPONSE_VALIDATOR);
76
    }
77
78 3
    public function listDevicesResponse(): \stdClass
79
    {
80 3
        return json_decode(self::LIST_DEVICES_RESPONSE_VALIDATOR);
81
    }
82
83 3
    public function acquireResponse(): \stdClass
84
    {
85 3
        return json_decode(self::ACQUIRE_RESPONSE_VALIDATOR);
86
    }
87
88 3
    public function releaseResponse(): \stdClass
89
    {
90 3
        return json_decode(self::RELEASE_RESPONSE_VALIDATOR);
91
    }
92
}
93