ParsesJson   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 17
ccs 5
cts 5
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseJson() 0 9 3
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
}