1: <?php declare(strict_types = 1);
2:
3: namespace ApiGen\Info;
4:
5: use function strrpos;
6: use function strtolower;
7: use function substr;
8:
9:
10: class NameInfo
11: {
12: /** @var string e.g. 'ApiGen\Info\Traits\HasName' */
13: public string $full;
14:
15: /** @var string e.g. 'apigen\info\traits\hasname' */
16: public string $fullLower;
17:
18: /** @var string e.g. 'HasName' */
19: public string $short;
20:
21: /** @var string e.g. 'hasname' */
22: public string $shortLower;
23:
24: /** @var string e.g. 'ApiGen\Info\Traits' */
25: public string $namespace;
26:
27: /** @var string e.g. 'apigen\info\traits' */
28: public string $namespaceLower;
29:
30:
31: public function __construct(string $full, ?string $fullLower = null)
32: {
33: $pos = strrpos($full, '\\');
34:
35: $this->full = $full;
36: $this->fullLower = $fullLower ?? strtolower($full);
37:
38: $this->short = $pos === false ? $full : substr($full, $pos + 1);
39: $this->shortLower = strtolower($this->short);
40:
41: $this->namespace = $pos === false ? '' : substr($full, 0, $pos);
42: $this->namespaceLower = strtolower($this->namespace);
43: }
44: }
45: