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

TSeparated::compactInt()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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