Passed
Push — master ( b28c40...f61e74 )
by Petr
08:06
created

TSeparated   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A separateInt() 0 3 1
A compactInt() 0 3 1
1
<?php
2
3
namespace kalanis\kw_auth\Traits;
4
5
6
use kalanis\kw_auth\Interfaces\IFile;
7
8
9
/**
10
 * Trait TSeparated
11
 * @package kalanis\kw_auth\Traits
12
 * Separate values in entry
13
 */
14
trait TSeparated
15
{
16
    /**
17
     * @param string $parent
18
     * @param string $separator
19
     * @return int[]
20
     */
21 14
    public function separateInt(string $parent, string $separator = IFile::PARENT_SEPARATOR): array
22
    {
23 14
        return array_values(array_filter(array_map('intval', array_filter((array) explode($separator, $parent)))));
24
    }
25
26
    /**
27
     * @param int[] $parent
28
     * @param string $separator
29
     * @return string
30
     */
31 8
    public function compactInt(array $parent, string $separator = IFile::PARENT_SEPARATOR): string
32
    {
33 8
        return implode($separator, array_values(array_filter(array_map('strval', $parent))));
34
    }
35
}
36