Example #1
0
 /**
  * @param string[] $paths
  * @throws CM_Exception_Invalid
  * @return array
  */
 public static function getClasses(array $paths)
 {
     $classes = array();
     foreach ($paths as $path) {
         $file = CM_File::factory($path);
         if (!$file instanceof CM_File_ClassInterface) {
             throw new CM_Exception_Invalid('Can only accept Class files. Given path is not one.', null, ['path' => $path]);
         }
         $meta = $file->getClassDeclaration();
         $classes[$meta['class']] = array('parent' => $meta['parent'], 'path' => $path);
     }
     $paths = array();
     while (count($classes)) {
         foreach ($classes as $class => $data) {
             if (!isset($classes[$data['parent']])) {
                 $paths[$data['path']] = $class;
                 unset($classes[$class]);
             }
         }
     }
     return $paths;
 }