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

Escaper::escape()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 6
nop 1
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
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