Completed
Push — master ( fb040e...52ef18 )
by Abdelrahman
10:47 queued 09:24
created

Escaper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A escape() 0 16 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Support\Traits;
6
7
trait Escaper
8
{
9
    /**
10
     * Escape all values.
11
     *
12
     * @param array $data
13
     *
14
     * @return array
15
     */
16
    protected function escape(array $data): array
17
    {
18
        $arrayDot = array_filter(array_dot($data));
19
20
        foreach ($arrayDot as $key => $value) {
21
            if (is_string($value)) {
22
                $arrayDot[$key] = e($value);
23
            }
24
        }
25
26
        foreach ($arrayDot as $key => $value) {
27
            array_set($data, $key, $value);
28
        }
29
30
        return $data;
31
    }
32
}
33