@@ -31,6 +31,7 @@ abstract class Bundle implements BundleInterface
31
31
protected $ name ;
32
32
protected $ extension ;
33
33
protected $ path ;
34
+ private $ namespace ;
34
35
35
36
/**
36
37
* Boots the Bundle.
@@ -106,9 +107,11 @@ public function getContainerExtension()
106
107
*/
107
108
public function getNamespace ()
108
109
{
109
- $ class = get_class ($ this );
110
+ if (null === $ this ->namespace ) {
111
+ $ this ->parseClassName ();
112
+ }
110
113
111
- return substr ( $ class , 0 , strrpos ( $ class , '\\' )) ;
114
+ return $ this -> namespace ;
112
115
}
113
116
114
117
/**
@@ -142,14 +145,11 @@ public function getParent()
142
145
*/
143
146
final public function getName ()
144
147
{
145
- if (null ! == $ this ->name ) {
146
- return $ this ->name ;
148
+ if (null = == $ this ->name ) {
149
+ $ this ->parseClassName () ;
147
150
}
148
151
149
- $ name = get_class ($ this );
150
- $ pos = strrpos ($ name , '\\' );
151
-
152
- return $ this ->name = false === $ pos ? $ name : substr ($ name , $ pos + 1 );
152
+ return $ this ->name ;
153
153
}
154
154
155
155
/**
@@ -218,4 +218,11 @@ protected function createContainerExtension()
218
218
return new $ class ();
219
219
}
220
220
}
221
+
222
+ private function parseClassName ()
223
+ {
224
+ $ pos = strrpos (static ::class, '\\' );
225
+ $ this ->namespace = false === $ pos ? '' : substr (static ::class, 0 , $ pos );
226
+ $ this ->name = false === $ pos ? static ::class : substr (static ::class, $ pos + 1 );
227
+ }
221
228
}
0 commit comments