Example #1
0
 /**
  * 
  * @param string $namespace
  * @throws TypeLoaderErrorException
  * @return array
  */
 public static function getNamespaceDirPaths($namespace)
 {
     if (ReflectionUtils::hasSpecialChars($namespace, false)) {
         throw new \InvalidArgumentException('Namespace contains invalid characters: ' . $namespace);
     }
     $dirPaths = array();
     foreach ($this->buildPs4Paths($namespace, '') as $psr4Path) {
         if (!is_dir($psr4Path)) {
             $dirPaths[] = $psr4Path;
         }
     }
     foreach (explode(PATH_SEPARATOR, get_include_path()) as $includePath) {
         $path = $includePath . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
         if (is_dir($path)) {
             $dirPaths[] = $path;
         }
     }
     return $dirPaths;
 }
Example #2
0
File: VarStore.php Project: n2n/n2n
 public static function dirNameToNamespace(string $dirName)
 {
     $namespace = ReflectionUtils::decodeNamespace($dirName);
     if (ReflectionUtils::hasSpecialChars($namespace, false)) {
         throw new \InvalidArgumentException('Invalid namespace: ' . $namespace);
     }
     return $namespace;
 }