EscapeHtmlDecorator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 5
cp 1
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 for escaping HTML entities in strings on the response.
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 1
    public function make(array $data, int $status, array $headers = []): JsonResponse
25
    {
26
        array_walk_recursive($data, function (&$value) {
27 1
            if (is_string($value)) {
28 1
                $value = e($value);
29
            }
30 1
        });
31
32 1
        return $this->factory->make($data, $status, $headers);
33
    }
34
}