JSONDecoder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 12
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getData() 0 9 2
1
<?php
2
3
namespace Wambo\Core\Storage;
4
5
use Wambo\Core\Storage\Exception\RuntimeException;
6
7
/**
8
 * Class JSONDecoder
9
 * @package Wambo\Core\Storage
10
 */
11
class JSONDecoder
12
{
13 5
    public function getData(string $json)
14
    {
15 5
        $data = json_decode($json, true);
16 5
        if ($error = json_last_error() !== JSON_ERROR_NONE) {
0 ignored issues
show
Unused Code introduced by
$error is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
17 1
            throw new RuntimeException(json_last_error_msg());
18
        }
19
20 4
        return $data;
21
    }
22
}