Passed
Push — master ( 623891...a57e97 )
by Alexander
01:13
created

EscapeHtmlDecorator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 10 2
1
<?php
2
3
namespace App\Support;
4
5
use Flugg\Responder\Http\Responses\Decorators\ResponseDecorator;
6
use Illuminate\Http\JsonResponse;
7
8
/**
9
 * A decorator class which escapes HTML entities in strings returned by your API.
10
 *
11
 * @package flugger/laravel-responder
12
 * @author  Paolo Caleffi <[email protected]>
13
 * @license The MIT License
14
 */
15
class EscapeHtmlDecorator extends ResponseDecorator
16
{
17
    /**
18
     * Generate a JSON response.
19
     *
20
     * @param  array $data
21
     * @param  int $status
22
     * @param  array $headers
23
     * @return \Illuminate\Http\JsonResponse
24
     */
25
    public function make(array $data, int $status, array $headers = []): JsonResponse
26
    {
27
        array_walk_recursive($data, function (&$value) {
28
            if(is_string($value)) {
29
                $value = e($value);
30
            }
31
        });
32
33
        return $this->factory->make($data, $status, $headers);
34
    }
35
}