Passed
Pull Request — master (#11)
by Pavel
07:02
created

InvalidRequestException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 35.7%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 26
ccs 5
cts 14
cp 0.357
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A missingFields() 0 7 1
A invalidVersion() 0 7 1
A notAJsonRpc() 0 7 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