MethodErrorException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 4
A getData() 0 3 1
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 stdClass;
15
use Throwable;
16
17
/**
18
 * Class InvalidParamsException
19
 *
20
 * @package Onnov\JsonRpcServer\Exception
21
 */
22
class MethodErrorException extends RuntimeException
23
{
24
    /**
25
     * @var stdClass|null
26
     */
27
    protected $data;
28
29
    /**
30
     * InternalErrorException constructor.
31
     *
32
     * @param string         $message
33
     * @param int            $code
34
     * @param Throwable|null $previous
35
     * @param stdClass|null  $data
36
     */
37
    public function __construct(
38
        string $message = "",
39
        int $code = 0,
40
        Throwable $previous = null,
41
        stdClass $data = null
42
    ) {
43
        if ($previous !== null && $data === null) {
44
            $this->data = (object)[
45
                'exception' => get_class($previous),
46
                'code'      => $previous->getCode(),
47
                'file'      => $previous->getFile(),
48
                'line'      => $previous->getLine(),
49
            ];
50
        } elseif ($data !== null) {
51
            $this->data = $data;
52
        }
53
54
        parent::__construct($message, $code, $previous);
55
    }
56
57
    /**
58
     * @return stdClass|null
59
     */
60
    public function getData(): ?stdClass
61
    {
62
        return $this->data;
63
    }
64
}
65