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

JsonResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
dl 0
loc 15
rs 10
c 1
b 0
f 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 3 1
A body() 0 3 1
A rawBody() 0 3 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