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.

DataTypeMapper::map()   C
last analyzed

Complexity

Conditions 8
Paths 8

Size

Total Lines 36
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 8

Importance

Changes 5
Bugs 1 Features 2
Metric Value
c 5
b 1
f 2
dl 0
loc 36
ccs 16
cts 16
cp 1
rs 5.3846
cc 8
eloc 16
nc 8
nop 1
crap 8
1
<?php
2
3
/*
4
 * This file is part of the json-query-wrapper package.
5
 *
6
 * (c) Enrico Stahn <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace JsonQueryWrapper;
13
14
use JsonQueryWrapper\Exception\DataTypeMapperException;
15
16
/**
17
 * Map data returned from jq to PHP data types.
18
 */
19
class DataTypeMapper
20
{
21
    /**
22
     * Returns a PHP typed value.
23
     *
24
     * @param string $value
25
     *
26
     * @throws DataTypeMapperException
27
     *
28
     * @return mixed
29
     */
30 8
    public function map($value)
31
    {
32 8
        if ($value === 'true') {
33 1
            return true;
34
        }
35
36 8
        if ($value === 'false') {
37 1
            return false;
38
        }
39
40 7
        if ($value === 'null') {
41 1
            return;
42
        }
43
44
        // Map integers
45 6
        if (preg_match('/^(\d+)$/', $value, $matches)) {
46 1
            return (int) $matches[1];
47
        }
48
49
        // Map floats
50 5
        if (preg_match('/^(\d+\.\d+)$/', $value, $matches)) {
51 1
            return (float) $matches[1];
52
        }
53
54
        // Map strings
55 4
        if (preg_match('/^"(.*)"$/', $value, $matches)) {
56 2
            return $matches[1];
57
        }
58
59
        // Map parser error
60 2
        if (preg_match('/^parse error: (.*)$/', $value, $matches)) {
61 1
            throw new DataTypeMapperException($matches[1]);
62
        }
63
64 1
        return $value;
65
    }
66
}
67