JsonDecoder::decode()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 4
nc 2
nop 2
dl 0
loc 8
rs 9.2
c 1
b 0
f 0
1
<?php
2
3
namespace Abraham\TwitterOAuth\Util;
4
5
/**
6
 * @author louis <[email protected]>
7
 */
8
class JsonDecoder
9
{
10
    /**
11
     * Decodes a JSON string to stdObject or associative array
12
     *
13
     * @param string $string
14
     * @param bool   $asArray
15
     *
16
     * @return array|object
17
     */
18
    public static function decode($string, $asArray)
19
    {
20
        if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
21
            return json_decode($string, $asArray, 512, JSON_BIGINT_AS_STRING);
22
        }
23
24
        return json_decode($string, $asArray);
25
    }
26
}
27