Completed
Push — 1.x ( afda62...f90c20 )
by Akihito
25s queued 12s
created

ImportApp::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 3
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 dirname;
11
use function is_dir;
12
use function sprintf;
13
14
final class ImportApp
15
{
16
    public string $host;
17
    public string $appName;
18
    public string $context;
19
    public string $appDir;
20
21
    public function __construct(string $host, string $appName, string $context)
22
    {
23
        $this->host = $host;
24
        $this->appName = $appName;
25
        $this->context = $context;
26
        /** @var class-string $appModuleClass */
27
        $appModuleClass = sprintf('%s\\Module\\AppModule', $this->appName);
28
        $appModuleClassName = (string) (new ReflectionClass($appModuleClass))->getFileName();
29
        $appDir = dirname($appModuleClassName, 3);
30
        assert(is_dir($appDir));
31
        $this->appDir = $appDir;
32
    }
33
}
34