AParser   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A removeNullBytes() 0 3 1
1
<?php
2
3
namespace kalanis\kw_input\Parsers;
4
5
6
/**
7
 * Class AParser
8
 * @package kalanis\kw_input\Parsers
9
 * Parse any input for problematic chars
10
 */
11
abstract class AParser
12
{
13
    /**
14
     * Parse input into usable array, remove problematic things
15
     * @param int[]|string[]|int[][]|string[][] $input
16
     * @return int[]|string[]|int[][]|string[][]
17
     */
18
    abstract public function parseInput(array $input): array;
19
20
    /**
21
     * Clear Null bytes
22
     * Do not use on files - they are usually valid
23
     * @param string $string
24
     * @param string $nullTo
25
     * @return string
26
     * @link https://resources.infosecinstitute.com/null-byte-injection-php/
27
     */
28 14
    protected function removeNullBytes($string, $nullTo = '')
29
    {
30 14
        return str_replace(chr(0), $nullTo, $string);
31
    }
32
}
33