In my code I have a method that uses get_class to get the name of the class. For example, if you had the User class, you would store that class name in a variable.
I recently started using the namespace with psr-4, but now that function get_class returns the namespace of the class. In other words, User returns App \ Models \ User
How can I make it work as before without removing the namespace?
This is the method, only the part of the get_class ($ this) is the one that works like I do not want:
public function parseClassNameToTable(){
$className = preg_replace('/(?<=\w)(\p{Lu})/u', '_$1', get_class($this));
$className = mb_strtolower($className);
return $className . 's';
}