PHP code example of laudirbispo / classname
1. Go to this page and download the library: Download laudirbispo/classname library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laudirbispo / classname example snippets
use laudirbispo\classname\ClassName;
$exampleClass = 'namespace\namspace2\MyClass';
// or
$exampleClass = new MyClass;
var_dump(ClassName::full($exampleClass));
// return string 'namespace\namspace2\MyClass' (length=27)
var_dump(ClassName::namespace($exampleClass));
// return string 'namespace\namspace2' (length=19)
var_dump(ClassName::short($exampleClass));
//return string 'MyClass' (length=7)
var_dump(ClassName::canonical($exampleClass));
// return string 'namespace.namspace2.MyClass' (length=27)
// Get parent class name or null
// @param $return string - full, namespace, canonical short - default is dull
var_dump(ClassName::getParent($exampleClass, string $return = 'full'));