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   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 2 Features 2
Metric Value
c 6
b 2
f 2
dl 0
loc 48
wmc 8
lcom 0
cbo 1
ccs 16
cts 16
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C map() 0 36 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