TSeparate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A separateModule() 0 14 4
1
<?php
2
3
namespace kalanis\kw_modules\Loaders;
4
5
6
use kalanis\kw_modules\ModuleException;
7
use kalanis\kw_modules\Traits\TMdLang;
8
9
10
/**
11
 * Trait TSeparate
12
 * @package kalanis\kw_modules\Loaders
13
 * Separate module name and internal path
14
 */
15
trait TSeparate
16
{
17
    use TMdLang;
18
19
    /**
20
     * @param string[] $path
21
     * @param string|null $emptyDefault
22
     * @throws ModuleException
23
     * @return string[]
24
     */
25 4
    protected function separateModule(array $path, ?string $emptyDefault = null): array
26
    {
27 4
        if (empty($path)) {
28 1
            throw new ModuleException($this->getMdLang()->mdNoModuleFound());
29
        }
30
31 3
        $target = strval(reset($path));
32 3
        $constructPath = is_null($emptyDefault) ? $target : $emptyDefault ;
33
34 3
        if (1 < count($path)) {
35 2
            $constructPath = implode('\\', array_slice($path, 1));
36
        }
37
38 3
        return [$target, $constructPath];
39
    }
40
}
41