Files   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseInput() 0 8 2
A clear() 0 6 2
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