Passed
Push — add-command-list-modules ( fd1ae6...c98401 )
by Chema
02:58
created

AppModule   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 37
ccs 19
cts 19
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromClass() 0 11 1
A facadeClass() 0 6 1
A __construct() 0 5 1
A moduleName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Console\Domain\AllAppModules;
6
7
final class AppModule
8
{
9 2
    public function __construct(
10
        private string $moduleName,
11
        private string $className,
12
        private string $namespace,
13
    ) {
14 2
    }
15
16 2
    public static function fromClass(string $fullyQualifiedClassName): self
17
    {
18 2
        $parts = explode('\\', $fullyQualifiedClassName);
19 2
        $className = array_pop($parts);
20 2
        $moduleName = (string)end($parts);
21 2
        $namespace = implode('\\', $parts);
22
23 2
        return new self(
24 2
            $moduleName,
25 2
            $className,
26 2
            $namespace,
27 2
        );
28
    }
29
30 1
    public function moduleName(): string
31
    {
32 1
        return $this->moduleName;
33
    }
34
35
    /**
36
     * @return class-string
37
     */
38 2
    public function facadeClass(): string
39
    {
40 2
        return sprintf(
41 2
            '%s\\%s',
42 2
            $this->namespace,
43 2
            $this->className,
44 2
        );
45
    }
46
}
47