ParsesJson::parseJson()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 10
1
<?php
2
3
namespace Propaganistas\LaravelDisposableEmail\Traits;
4
5
trait ParsesJson
6
{
7
    /**
8
     * Parses the given JSON into a native array. Returns false on errors.
9
     *
10
     * @param string $data
11
     * @return array|bool
12
     */
13 63
    protected function parseJson($data)
14
    {
15 63
        $data = json_decode($data, true);
16
17 63
        if (json_last_error() !== JSON_ERROR_NONE || empty($data)) {
18 9
            return false;
19
        }
20
21 63
        return $data;
22
    }
23
}