Passed
Pull Request — 1.x (#394)
by Akihito
01:44
created

ImportApp   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 13
c 2
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Package\Module\Import;
6
7
use ReflectionClass;
8
9
use function assert;
10
use function class_exists;
11
use function dirname;
12
use function is_dir;
13
use function sprintf;
14
15
final class ImportApp
16
{
17
    public string $host;
18
    public string $appName;
19
    public string $context;
20
    public string $appDir;
21
22
    public function __construct(string $host, string $appName, string $context)
23
    {
24
        $this->host = $host;
25
        $this->appName = $appName;
26
        $this->context = $context;
27
        $appModuleClass = sprintf('%s\\Module\\AppModule', $this->appName);
28
        assert(class_exists($appModuleClass));
29
        $appModuleClassName = (string) (new ReflectionClass($appModuleClass))->getFileName();
30
        $appDir = dirname($appModuleClassName, 3);
31
        assert(is_dir($appDir));
32
        $this->appDir = $appDir;
33
    }
34
}
35