Passed
Pull Request — master (#11)
by Pavel
06:35
created

InvalidRequestException::missingFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Bankiru\Api\JsonRpc\Exception;
4
5
use ScayTrase\Api\JsonRpc\JsonRpcError;
6
7
class InvalidRequestException extends JsonRpcException
8
{
9 6
    public static function missingFields(array $fields)
10
    {
11 6
        return self::create(
12 6
            JsonRpcError::INVALID_REQUEST,
13 6
            sprintf('Invalid JSONRPC 2.0 Request. Missing fields %s', implode(', ', $fields))
14 6
        );
15
    }
16
17
    public static function invalidVersion($expected, $actual)
18
    {
19
        return self::create(
20
            JsonRpcError::INVALID_REQUEST,
21
            sprintf('Invalid JSONRPC 2.0 Request. Version mismatch: %s expected, %s given', $expected, $actual)
22
        );
23
    }
24
25
    public static function notAJsonRpc()
26
    {
27
        return self::create(
28
            JsonRpcError::INVALID_REQUEST,
29
            'Not a JSONRPC 2.0 Request'
30
        );
31
    }
32
}
33