-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathClassString.php
41 lines (34 loc) · 1.12 KB
/
ClassString.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace ApiClients\Tools\OpenApiClientGenerator;
use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_;
use function trim;
final readonly class ClassString
{
public static function factory(Namespace_ $namespace, string $relative): self
{
$relative = trim(Utils::className($relative), '\\');
$fullyQualified = new Namespace_(
Utils::cleanUpNamespace(trim($namespace->source, '\\') . '\\' . $relative),
Utils::cleanUpNamespace(trim($namespace->test, '\\') . '\\' . $relative),
);
return new self(
$namespace,
new Namespace_(
Utils::dirname($fullyQualified->source),
Utils::dirname($fullyQualified->test),
),
$fullyQualified,
$relative,
Utils::basename($relative),
);
}
private function __construct(
public Namespace_ $baseNamespaces,
public Namespace_ $namespace,
public Namespace_ $fullyQualified,
public string $relative,
public string $className,
) {
}
}