Files::clear()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace kalanis\kw_input\Parsers;
4
5
6
/**
7
 * Class Files
8
 * @package kalanis\kw_input\Parsers
9
 * Parse files input
10
 * Check only names, the rest is usually valid
11
 */
12
class Files extends AParser
13
{
14 3
    public function parseInput(array $input): array
15
    {
16 3
        $trimArray = [];
17 3
        foreach ($input as $key => &$posted) {
18 3
            $posted['name'] = $this->clear($posted['name']);
19 3
            $trimArray[$this->removeNullBytes(trim(strval($key)))] = $posted;
20
        }
21 3
        return $trimArray;
22
    }
23
24 3
    protected function clear($value)
25
    {
26 3
        if (is_array($value)) {
27 3
            return array_map([$this, 'clear'], $value);
28
        } else {
29 3
            return $this->removeNullBytes(trim(strval($value)));
30
        }
31
    }
32
}
33