Passed
Push — master ( d309df...7ec489 )
by Petr
02:37
created

TLines::stripChars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace kalanis\kw_auth\Sources\Files;
4
5
6
use kalanis\kw_auth\Interfaces\IFile;
7
8
9
/**
10
 * Trait TLines
11
 * @package kalanis\kw_auth\Sources\Files
12
 * Processing lines of accounts in files
13
 */
14
trait TLines
15
{
16
    /**
17
     * @param string $input
18
     * @return array<int, string>
19
     */
20 38
    public function explosion(string $input): array
21
    {
22 38
        return explode(IFile::SEPARATOR, $input);
23
    }
24
25
    /**
26
     * @param array<int, string|int|float> $input
27
     * @return string
28
     */
29 17
    public function implosion(array $input): string
30
    {
31 17
        return implode(IFile::SEPARATOR, $input + ['']);
32
    }
33
34
    /**
35
     * @param string $input
36
     * @return bool
37
     */
38 35
    public function filterEmptyLines(string $input): bool
39
    {
40 35
        return !empty($input) && ('#' !== $input[0]);
41
    }
42
43 43
    public function stripChars(string $input): string
44
    {
45 43
        return strval(preg_replace('#[^a-zA-Z0-9\,\*\/\.\-\+\?\_\§\"\!\/\(\)\|\€\'\\\&\@\{\}\<\>\#\ ]#', '', $input));
46
    }
47
}
48