GetNamespace::getNamespace()
Not yet in a tagged release
Description
GetNamespace::getNamespace() returns a class or object's namespace.
use GanbaroDigital\MissingBits\TypeInspectors\GetNamespace;
public string GetNamespace::getNamespace(string|object $item);
Parameters
The input parameters are:
$item- the item to examine. Must an object, or a string containing the name of a valid class, interface or trait.
Return Value
GetNamespace::getNamespace() returns a string. It contains the namespace that the class or object is defined in.
- if the class or object has a namespace, that namespace is returned
 - if the class or object has no namespace, an empty string is returned
 
Throws
GetNamespace::getNamespace() throws these exceptions:
- if 
$itemis not an object or string,InvalidArgumentExceptionis thrown - if 
$itemis a string, but does not contain a defined class, interface or trait,InvalidArgumentExceptionis thrown 
Works With
GetNamespace::getNamespace() is supported on these versions of PHP:
| PHP Version | Works? | 
|---|---|
| 5.5 | Yes | 
| 5.6 | Yes | 
| 7.0 | Yes | 
| HHVM | Yes |