Passed
Push — master ( c63d54...5125b8 )
by Roy
04:56 queued 12s
created

Entity   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 13
dl 0
loc 30
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassName() 0 5 2
A getClassNamespace() 0 5 2
A convertPathToNamespace() 0 8 2
A getPathBeforeClassName() 0 3 1
1
<?php
2
3
namespace LaravelModulize\Support;
4
5
use Illuminate\Support\Str;
6
7
class Entity
8
{
9 8
    public static function getClassName($name)
10
    {
11 8
        return Str::contains($name, '/')
12 6
            ? array_reverse(explode('/', $name, 2))[0]
13 8
            : $name;
14
    }
15
16 2
    public static function getClassNamespace($name)
17
    {
18 2
        return Str::contains($name, '/')
19 2
            ? self::convertPathToNamespace($name)
20 2
            : '';
21
    }
22
23 2
    public static function convertPathToNamespace($name)
24
    {
25 2
        return Str::contains($name, '/')
26 2
            ? Str::start(
27 2
                str_replace('/', '', self::getPathBeforeClassName($name)),
28 2
                '\\'
29
            )
30 2
            : '';
31
32
    }
33
34 4
    public static function getPathBeforeClassName($name)
35
    {
36 4
        return Str::before($name, self::getClassName($name));
37
    }
38
}
39