GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Decoder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 5
c 3
b 2
f 0
lcom 1
cbo 1
dl 0
loc 77
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A decode() 0 6 1
A setDecodeAsArray() 0 5 1
A setDecodeAsObject() 0 5 1
A setDecodeDepth() 0 5 1
A enableBigIntAsString() 0 4 1
1
<?php
2
/**
3
 * Decoder
4
 *
5
 * @author Kachit
6
 */
7
namespace Kachit\Helper\Json;
8
9
class Decoder extends AbstractJson
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $options = [
15
        JSON_BIGINT_AS_STRING => false,
16
    ];
17
18
    /**
19
     * @var bool
20
     */
21
    protected $decodeAsArray = true;
22
23
    /**
24
     * @var int
25
     */
26
    protected $decodeDepth = 512;
27
28
    /**
29
     * Decode json string to value
30
     *
31
     * @param string $jsonString
32
     * @return mixed
33
     */
34
    public function decode($jsonString)
35
    {
36
        $value = json_decode($jsonString, $this->decodeAsArray, $this->decodeDepth, $this->generateOptions());
37
        $this->checkJsonErrors();
38
        return $value;
39
    }
40
41
    /**
42
     * Set decode as array
43
     *
44
     * @return $this;
0 ignored issues
show
Documentation introduced by
The doc-type $this; could not be parsed: Expected "|" or "end of type", but got ";" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
45
     */
46
    public function setDecodeAsArray()
47
    {
48
        $this->decodeAsArray = true;
49
        return $this;
50
    }
51
52
    /**
53
     * Set decode as object
54
     *
55
     * @return $this;
0 ignored issues
show
Documentation introduced by
The doc-type $this; could not be parsed: Expected "|" or "end of type", but got ";" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
56
     */
57
    public function setDecodeAsObject()
58
    {
59
        $this->decodeAsArray = false;
60
        return $this;
61
    }
62
63
    /**
64
     * Set decode depth
65
     *
66
     * @param int $decodeDepth
67
     * @return $this;
0 ignored issues
show
Documentation introduced by
The doc-type $this; could not be parsed: Expected "|" or "end of type", but got ";" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
68
     */
69
    public function setDecodeDepth($decodeDepth)
70
    {
71
        $this->decodeDepth = (int)$decodeDepth;
72
        return $this;
73
    }
74
75
    /**
76
     * Set encode option JSON_BIGINT_AS_STRING
77
     *
78
     * @param bool $value
79
     * @return $this
80
     */
81
    public function enableBigIntAsString($value = true)
82
    {
83
        return $this->setOption(JSON_BIGINT_AS_STRING, $value);
84
    }
85
}