forked from laminas/laminas-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathName.php
40 lines (33 loc) · 812 Bytes
/
Name.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
<?php
namespace Laminas\Code\Generator\EnumGenerator;
use function strrpos;
use function substr;
/**
* @internal
*
* @psalm-immutable
*/
final class Name
{
private function __construct(private readonly string $name, private readonly ?string $namespace)
{
}
public function getName(): string
{
return $this->name;
}
public function getNamespace(): ?string
{
return $this->namespace;
}
public static function fromFullyQualifiedClassName(string $name): self
{
$namespace = null;
$nsPosition = strrpos($name, '\\');
if (false !== $nsPosition) {
$namespace = substr($name, 0, $nsPosition);
$name = substr($name, $nsPosition + 1);
}
return new self($name, $namespace);
}
}