Assuming I have the following classes in different files:
You can also do this in your getNamespace() method:
return get_class($this);
When called from childclass, the result will be:
MyNS\SubNS\childclass
If you don't want the class name on the end, just chop off everything from the last \ to the end.