Passed
Push — master ( ed3164...71916c )
by Petr
02:23
created

TLines   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A implosion() 0 3 1
A filterEmptyLines() 0 3 2
A stripChars() 0 3 1
A explosion() 0 3 1
1
<?php
2
3
namespace kalanis\kw_auth_sources\Traits;
4
5
6
use kalanis\kw_auth_sources\Interfaces\IFile;
7
use kalanis\kw_paths\Extras\TPathTransform;
8
use kalanis\kw_paths\PathsException;
9
10
11
/**
12
 * Trait TLines
13
 * @package kalanis\kw_auth_sources\Traits
14
 * Processing lines of accounts in files
15
 */
16
trait TLines
17
{
18
    use TPathTransform;
19
20
    /**
21
     * @param string $input
22
     * @throws PathsException
23
     * @return array<int, string>
24
     */
25 22
    public function explosion(string $input): array
26
    {
27 22
        return $this->expandName($input,IFile::SEPARATOR);
28
    }
29
30
    /**
31
     * @param array<int, string|int|float> $input
32
     * @throws PathsException
33
     * @return string
34
     */
35 12
    public function implosion(array $input): string
36
    {
37 12
        return $this->compactName(array_map('strval', $input + ['']), IFile::SEPARATOR);
38
    }
39
40
    /**
41
     * @param string $input
42
     * @return bool
43
     */
44 19
    public function filterEmptyLines(string $input): bool
45
    {
46 19
        return !empty($input) && ('#' !== $input[0]);
47
    }
48
49 26
    public function stripChars(string $input): string
50
    {
51 26
        return strval(preg_replace('#[^a-zA-Z0-9\,\*\/\.\-\+\?\_\§\"\!\/\(\)\|\€\'\\\&\@\{\}\<\>\#\ ]#', '', $input));
52
    }
53
}
54