Failed Conditions
Push — feature/app-dev ( 333f67 )
by Yo
01:46
created

JsonRpcInvalidRequestException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Yoanm\JsonRpcServer\Domain\Exception;
3
4
/**
5
 * Class JsonRpcInvalidRequestException
6
 */
7
class JsonRpcInvalidRequestException extends JsonRpcException
8
{
9
    const CODE = -32600;
10
11
    const CONTENT_KEY = 'content';
12
    const DESCRIPTION_KEY = 'description';
13
14
    /**
15
     * @param mixed  $content Request parsed content
16
     * @param string $message Optional description
17
     */
18 2
    public function __construct($content, string $description = null)
19
    {
20 2
        $data = [self::CONTENT_KEY => $content];
21 2
        if ($description) {
22 1
            $data[self::DESCRIPTION_KEY] = $description;
23
        }
24 2
        parent::__construct(self::CODE, 'Parse error', $data);
25 2
    }
26
}
27