JsonDecoder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A decodeData() 0 7 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: claudio
5
 * Date: 17/09/15
6
 * Time: 14.44
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 */
19
20
namespace it\thecsea\api_reflection;
21
22
/**
23
 * Class JsonDecoder
24
 * @package it\thecsea\api_reflection
25
 * @author Claudio Cardinale <[email protected]>
26
 * @copyright 2015 Claudio Cardinale
27
 * @version 1.0.0
28
 */
29
class JsonDecoder extends GeneralDecoder
30
{
31
    /**
32
     * Decode the data into a standard array that contains apiKey, class and method name and array of paramters
33
     * @param mixed $data
34
     * @return array
35
     */
36
    public function decodeData($data)
37
    {
38
        $decoded = json_decode($data, true);
39
        if(!self::isValid($decoded))
40
            throw new ApiReflectionException("Decode error (data)");
41
        return $decoded;
42
    }
43
}