Total Complexity | 10 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
13 | final class JsonBodyParser implements MiddlewareInterface |
||
14 | { |
||
15 | private const DEFAULT_FLAGS = JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE; |
||
16 | private bool $assoc = true; |
||
17 | private int $depth = 512; |
||
18 | private int $options = self::DEFAULT_FLAGS; |
||
19 | |||
20 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
31 | } |
||
32 | |||
33 | public function withAssoc(): self |
||
34 | { |
||
35 | $new = clone $this; |
||
36 | $new->assoc = true; |
||
37 | return $new; |
||
38 | } |
||
39 | |||
40 | public function withoutAssoc(): self |
||
41 | { |
||
42 | $new = clone $this; |
||
43 | $new->assoc = false; |
||
44 | return $new; |
||
45 | } |
||
46 | |||
47 | public function withDepth(int $value): self |
||
52 | } |
||
53 | |||
54 | public function withOptions(int $value): self |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return mixed |
||
63 | */ |
||
64 | private function parse(string $body) |
||
71 | } |
||
72 | } |
||
73 |