Passed
Pull Request — master (#38)
by
unknown
03:49
created

JsonDecodeException::getJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of Guzzle HTTP JSON-RPC
5
 *
6
 * Copyright (c) 2014 Nature Delivered Ltd. <http://graze.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @see  http://github.com/graze/guzzle-jsonrpc/blob/master/LICENSE
12
 * @link http://github.com/graze/guzzle-jsonrpc
13
 */
14
15
namespace Graze\GuzzleHttp\JsonRpc\Exception;
16
17
use Throwable;
18
19
class JsonDecodeException extends \InvalidArgumentException
20
{
21
    /**
22
     * @var string
23
     */
24
    private $json;
25
26
    /**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$json" missing
Loading history...
27
     * JsonDecodeException constructor.
28
     * @param string $message
29
     * @param int $code
30
     * @param Throwable|null $previous
31
     * @param $json
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
32
     */
33
    public function __construct($message = "", $code = 0, Throwable $previous = null, $json)
0 ignored issues
show
Coding Style introduced by
Type hint "json" missing for
Loading history...
Coding Style introduced by
Parameters which have default values should be placed at the end.

If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway:

// $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
34
    {
35
        parent::__construct($message, $code, $previous);
36
        $this->json = $json;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getJson()
43
    {
44
        return $this->json;
45
    }
46
}
47