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

ResponseHelperTrait::getResponseJsonArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
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\Bundle\FrameworkBundle\Client;
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * @method Client getClient()
18
 *
19
 * @requires JsonHelperTrait
20
 */
21
trait ResponseHelperTrait
22
{
23 22
    public static function getResponse(): Response
24
    {
25 22
        return static::getClient()->getResponse();
0 ignored issues
show
Bug Best Practice introduced by
The method Ynlo\GraphQLBundle\Test\...elperTrait::getClient() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        return static::/** @scrutinizer ignore-call */ getClient()->getResponse();
Loading history...
Bug Best Practice introduced by
The expression return static::getClient()->getResponse() could return the type null which is incompatible with the type-hinted return Symfony\Component\HttpFoundation\Response. Consider adding an additional type-check to rule them out.
Loading history...
26
    }
27
28 22
    public static function getResponseJsonArray(): array
29
    {
30 22
        return json_decode(static::getResponse()->getContent(), true);
31
    }
32
33
    /**
34
     * @param string $path
35
     *
36
     * @return mixed|null
37
     */
38 22
    public static function getResponseJsonPathValue(string $path)
39
    {
40 22
        return static::getJsonPathValue(static::getResponseJsonArray(), $path);
41
    }
42
}
43