Passed
Push — master ( a57e97...003aa3 )
by Alexander
01:12
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 Flugg\Responder\Http\Responses\Decorators;
4
5
use Illuminate\Http\JsonResponse;
6
7
/**
8
 * A decorator class which escapes HTML entities in strings returned by your API.
9
 *
10
 * @package flugger/laravel-responder
11
 * @author  Paolo Caleffi <[email protected]>
12
 * @license The MIT License
13
 */
14
class EscapeHtmlDecorator extends ResponseDecorator
15
{
16
    /**
17
     * Generate a JSON response.
18
     *
19
     * @param  array $data
20
     * @param  int $status
21
     * @param  array $headers
22
     * @return \Illuminate\Http\JsonResponse
23
     */
24
    public function make(array $data, int $status, array $headers = []): JsonResponse
25
    {
26
        array_walk_recursive($data, function (&$value) {
27
            if(is_string($value)) {
28
                $value = e($value);
29
            }
30
        });
31
32
        return $this->factory->make($data, $status, $headers);
33
    }
34
}