File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,26 @@ public static function getNodeName($path)
262
262
return substr ($ path , $ strrpos + 1 );
263
263
}
264
264
265
+ /**
266
+ * Return the localname of the node at the given path.
267
+ * The local name is the node name minus the namespace
268
+ *
269
+ * @param string $path a valid absolute path
270
+ *
271
+ * @return string The localname
272
+ */
273
+ public static function getLocalNodeName ($ path )
274
+ {
275
+ $ nodeName = self ::getNodeName ($ path );
276
+ $ localName = strstr ($ nodeName , ': ' );
277
+
278
+ if (false !== $ localName ) {
279
+ return substr ($ localName , 1 );
280
+ }
281
+
282
+ return $ nodeName ;
283
+ }
284
+
265
285
/**
266
286
* Get the depth of the path, ignore trailing slashes, root starts counting at 0
267
287
*
Original file line number Diff line number Diff line change @@ -268,6 +268,25 @@ public function dataproviderGetNodeName()
268
268
);
269
269
}
270
270
271
+ /**
272
+ * @dataProvider dataproviderGetLocalNodeName
273
+ */
274
+ public function testGetLocalNodeName ($ path , $ expected = null )
275
+ {
276
+ $ this ->assertEquals ($ expected , PathHelper::getLocalNodeName ($ path ));
277
+ }
278
+
279
+ public function dataproviderGetLocalNodeName ()
280
+ {
281
+ return array (
282
+ array ('/parent/child ' , 'child ' ),
283
+ array ('/foo:child ' , 'child ' ),
284
+ array ('/parent/ns:child ' , 'child ' ),
285
+ array ('/ns:parent/child:foo ' , 'foo ' ),
286
+ array ('/ ' , '' ),
287
+ );
288
+ }
289
+
271
290
/**
272
291
* @expectedException \PHPCR\RepositoryException
273
292
* @expectedExceptionMessage must be an absolute path
You can’t perform that action at this time.
0 commit comments