Completed
Push — master ( 533532...ee214c )
by Rafael
04:23
created

JsonHelperTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 15
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getJsonPathValue() 0 7 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Test\Helper;
12
13
use Symfony\Component\HttpFoundation\Response;
14
use function JmesPath\search;
15
16
/**
17
 * @method Response getResponse()
18
 */
19
trait JsonHelperTrait
20
{
21
    /**
22
     * @param string|array $json
23
     * @param string       $path
24
     *
25
     * @return mixed|null
26
     */
27 22
    public static function getJsonPathValue($json, string $path)
28
    {
29 22
        if (is_string($json)) {
30
            $json = json_decode($json, true);
31
        }
32
33 22
        return search($path, $json);
34
    }
35
}
36