ParseErrorException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 69.23%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 41
ccs 9
cts 13
cp 0.6923
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 3 1
A __construct() 0 18 4
1
<?php
2
3
/**
4
 * Created by PhpStorm.
5
 * Project: json_rpc_server
6
 * User: sv
7
 * Date: 24.06.19
8
 * Time: 17:55
9
 */
10
11
namespace Onnov\JsonRpcServer\Exception;
12
13
use RuntimeException;
14
use Throwable;
15
16
/**
17
 * Class ParseErrorException
18
 *
19
 * @package Onnov\JsonRpcServer\Exception
20
 */
21
class ParseErrorException extends RuntimeException
22
{
23
    /**
24
     * @var mixed[]
25
     */
26
    protected $data;
27
28
    /**
29
     * InternalErrorException constructor.
30
     *
31
     * @param string         $message
32
     * @param int            $code
33
     * @param Throwable|null $previous
34
     * @param mixed[]|null   $data
35
     */
36 1
    public function __construct(
37
        string $message = '',
38
        int $code = 0,
39
        Throwable $previous = null,
40
        array $data = null
41
    ) {
42 1
        if ($previous !== null && $data === null) {
43 1
            $this->data = [
44 1
                'exception' => get_class($previous),
45 1
                'code'      => $previous->getCode(),
46 1
                'file'      => $previous->getFile(),
47 1
                'line'      => $previous->getLine(),
48 1
            ];
49
        } elseif ($data !== null) {
50
            $this->data = $data;
51
        }
52
53 1
        parent::__construct($message, $code, $previous);
54
    }
55
56
    /**
57
     * @return mixed[]|null
58
     */
59
    public function getData(): ?array
60
    {
61
        return $this->data;
62
    }
63
}
64