This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/Rails/Toolbox/ClassTools.php
2013-10-02 01:12:58 -05:00

25 lines
514 B
PHP
Executable File

<?php
namespace Rails\Toolbox;
class ClassTools
{
/**
* Returns all parents of a class.
*
* @return array
*/
static public function getParents($className)
{
$parents = [];
$parent = new \ReflectionClass($className);
while (true) {
$parent = $parent->getParentClass();
if (!$parent) {
break;
} else {
$parents[] = $parent->getName();
}
}
return $parents;
}
}