Passed
Push — master ( a391b6...85ac84 )
by Tobias
01:43
created

PrettyPrint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 3
1
<?php
2
3
namespace TobyMaxham\Helper\Http\Middleware;
4
5
use Illuminate\Http\JsonResponse;
6
7
class PrettyPrint
8
{
9
    const QUERY_PARAMETER = 'pretty';
10
11
    public function handle($request, \Closure $next)
12
    {
13
        $response = $next($request);
14
15
        if ($response instanceof JsonResponse) {
16
            if ('true' == $request->query(self::QUERY_PARAMETER)) {
17
                $response->setEncodingOptions(JSON_PRETTY_PRINT);
18
            }
19
        }
20
21
        return $response;
22
    }
23
}
24