Passed
Push — 1.x ( 885d6a...11c6d3 )
by Kevin
01:56
created

JsonResponse::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Zenstruck\Browser\Response;
4
5
use Zenstruck\Browser\Response;
6
use function JmesPath\search;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
final class JsonResponse extends Response
12
{
13
    public function body()
14
    {
15
        return \json_decode(parent::body(), true, 512, JSON_THROW_ON_ERROR);
16
    }
17
18
    public function find(string $selector)
19
    {
20
        return search($selector, $this->body());
21
    }
22
23
    protected function rawBody(): string
24
    {
25
        return \json_encode($this->body(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
26
    }
27
}
28