55namespace Bigcommerce \Injector \Reflection ;
66
77use Bigcommerce \Injector \Cache \ServiceCacheInterface ;
8- use ReflectionClass ;
98use ReflectionException ;
109
1110class CachingClassInspector implements ClassInspectorInterface
@@ -44,14 +43,14 @@ public function warmCache(string $class, string $method): void
4443 public function classHasMethod (string $ class , string $ method ): bool
4544 {
4645 $ key = "$ class:: {$ method }::exists " ;
47- if (! $ this ->serviceCache ->has ($ key )) {
48- $ this ->serviceCache ->set (
49- $ key ,
50- $ this ->classInspector ->classHasMethod ($ class , $ method ),
51- );
46+ if ($ this ->serviceCache ->has ($ key )) {
47+ $ value = $ this ->serviceCache ->get ( $ key );
48+ } else {
49+ $ value = $ this ->classInspector ->classHasMethod ($ class , $ method );
50+ $ this -> serviceCache -> set ( $ key , $ value );
5251 }
5352
54- return $ this -> serviceCache -> get ( $ key ) ;
53+ return $ value ;
5554 }
5655
5756 /**
@@ -65,14 +64,14 @@ public function classHasMethod(string $class, string $method): bool
6564 public function methodIsPublic (string $ class , string $ method ): bool
6665 {
6766 $ key = "$ class:: {$ method }::is_public " ;
68- if (! $ this ->serviceCache ->has ($ key )) {
69- $ this ->serviceCache ->set (
70- $ key ,
71- $ this ->classInspector ->methodIsPublic ($ class , $ method ),
72- );
67+ if ($ this ->serviceCache ->has ($ key )) {
68+ $ value = $ this ->serviceCache ->get ( $ key );
69+ } else {
70+ $ value = $ this ->classInspector ->methodIsPublic ($ class , $ method );
71+ $ this -> serviceCache -> set ( $ key , $ value );
7372 }
7473
75- return $ this -> serviceCache -> get ( $ key ) ;
74+ return $ value ;
7675 }
7776
7877 /**
@@ -86,14 +85,14 @@ public function methodIsPublic(string $class, string $method): bool
8685 public function getMethodSignature (string $ class , string $ method ): array
8786 {
8887 $ key = "$ class:: {$ method }::signature " ;
89- if (! $ this ->serviceCache ->has ($ key )) {
90- $ this ->serviceCache ->set (
91- $ key ,
92- $ this ->classInspector ->getMethodSignature ($ class , $ method ),
93- );
88+ if ($ this ->serviceCache ->has ($ key )) {
89+ $ value = $ this ->serviceCache ->get ( $ key );
90+ } else {
91+ $ value = $ this ->classInspector ->getMethodSignature ($ class , $ method );
92+ $ this -> serviceCache -> set ( $ key , $ value );
9493 }
9594
96- return $ this -> serviceCache -> get ( $ key ) ;
95+ return $ value ;
9796 }
9897
9998 public function getStats (): ClassInspectorStats
0 commit comments