Decoder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A decode() 0 15 2
1
<?php
2
3
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5
namespace Json;
6
7
abstract class Decoder
8
{
9
    protected $assoc = false;
10
11
    protected $depth = 512;
12
13
    protected $options = 0;
14
15
    protected $error;
16
17
    public function __construct($depth = 512, $options = 0)
18
    {
19
        $this->depth = $depth;
20
        $this->options = $options;
21
22
        $this->error = new JsonError();
23
    }
24
25
    public function decode($string)
26
    {
27
        $decoded = json_decode(
28
            $string,
29
            $this->assoc,
30
            $this->depth,
31
            $this->options
32
        );
33
34
        if (false === $this->error->hasError()) {
35
            return $decoded;
36
        }
37
38
        $this->error->throwException();
39
    }
40
}
41