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

TLines   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 32
ccs 8
cts 8
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A stripChars() 0 3 1
A filterEmptyLines() 0 3 2
A implosion() 0 3 1
A explosion() 0 3 1
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