ImportApp::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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