Total Complexity | 19 |
Total Lines | 118 |
Duplicated Lines | 0 % |
Coverage | 92.16% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | final class DocBlockResolvable |
||
21 | { |
||
22 | /** @var array<string,string> [fileName => fileContent] cached */ |
||
23 | private static array $fileContentCache = []; |
||
24 | |||
25 | /** @var class-string */ |
||
1 ignored issue
–
show
|
|||
26 | private string $callerClass; |
||
27 | |||
28 | /** @var class-string|string */ |
||
1 ignored issue
–
show
|
|||
29 | private string $callerParentClass; |
||
30 | |||
31 | /** |
||
32 | * @param class-string $callerClass |
||
1 ignored issue
–
show
|
|||
33 | * @param class-string|string $callerParentClass |
||
34 | */ |
||
35 | 13 | private function __construct(string $callerClass, string $callerParentClass) |
|
36 | { |
||
37 | 13 | $this->callerClass = $callerClass; |
|
38 | 13 | $this->callerParentClass = $callerParentClass; |
|
39 | } |
||
40 | |||
41 | 13 | public static function fromCaller(object $caller): self |
|
46 | ); |
||
47 | } |
||
48 | |||
49 | 13 | public function getClassName(string $method): string |
|
60 | } |
||
61 | |||
62 | 11 | public function normalizeResolvableType(string $resolvableType): string |
|
63 | { |
||
64 | /** @var list<string> $resolvableTypeParts */ |
||
65 | 11 | $resolvableTypeParts = explode('\\', ltrim($resolvableType, '\\')); |
|
66 | 11 | $normalizedResolvableType = end($resolvableTypeParts); |
|
67 | |||
68 | 11 | return is_string($normalizedResolvableType) |
|
69 | 11 | ? $normalizedResolvableType |
|
70 | 11 | : $resolvableType; |
|
71 | } |
||
72 | |||
73 | public function hasParentClass(): bool |
||
74 | { |
||
75 | /** @psalm-suppress ArgumentTypeCoercion */ |
||
76 | return $this->callerParentClass !== '' |
||
77 | && method_exists($this->callerParentClass, '__call'); |
||
78 | } |
||
79 | |||
80 | 13 | private function generateCacheKey(string $method): string |
|
81 | { |
||
82 | 13 | return $this->callerClass . '::' . $method; |
|
83 | } |
||
84 | |||
85 | 13 | private function createClassNameCache(): ClassNameCacheInterface |
|
86 | { |
||
87 | 13 | if (!$this->isProjectCacheEnabled()) { |
|
88 | 4 | return new InMemoryCache(CustomServicesCache::class); |
|
89 | } |
||
90 | |||
91 | 9 | return new CustomServicesCache( |
|
92 | 9 | Config::getInstance()->getCacheDir() |
|
93 | ); |
||
94 | } |
||
95 | |||
96 | 13 | private function isProjectCacheEnabled(): bool |
|
97 | { |
||
98 | 13 | return (new GacelaCache(Config::getInstance())) |
|
99 | 13 | ->isProjectCacheEnabled(); |
|
100 | } |
||
101 | |||
102 | /** |
||
103 | * @return class-string |
||
1 ignored issue
–
show
|
|||
104 | */ |
||
105 | 11 | private function getClassFromDoc(string $method): string |
|
117 | } |
||
118 | |||
119 | 11 | private function searchClassOverDocBlock(ReflectionClass $reflectionClass, string $method): string |
|
124 | } |
||
125 | |||
126 | /** |
||
127 | * Look the uses, to find the fully-qualified class name for the className. |
||
128 | */ |
||
129 | 11 | private function searchClassOverUseStatements(ReflectionClass $reflectionClass, string $className): string |
|
140 |