PDepend\Util\Type::getTypePackage PHP Method

getTypePackage() public static method

Returns the package/extension for the given type name. If no package exists, this method will return null.
public static getTypePackage ( string $typeName ) : string
$typeName string The type name.
return string
    public static function getTypePackage($typeName)
    {
        self::initTypeToExtension();
        $normalizedName = ltrim($typeName, '\\');
        $normalizedName = strtolower($normalizedName);
        if (isset(self::$typeNameToExtension[$normalizedName])) {
            return self::$typeNameToExtension[$normalizedName];
        }
        return null;
    }

Usage Example

Beispiel #1
0
 /**
  * Extracts the package name of a qualified PHP 5.3 class identifier.
  *
  * If the class name doesn't contain a package identifier this method will
  * return the default identifier.
  *
  * <code>
  *   $namespaceName = $this->extractPackageName('foo\bar\foobar');
  *   var_dump($namespaceName);
  *   // Results in:
  *   // string(8) "foo\bar"
  *
  *   $namespaceName = $this->extractPackageName('foobar');
  *   var_dump($namespaceName);
  *   // Results in:
  *   // string(6) "+global"
  * </code>
  *
  * @param string $qualifiedName The qualified PHP 5.3 class identifier.
  *
  * @return string
  */
 protected function extractNamespaceName($qualifiedName)
 {
     if (($pos = strrpos($qualifiedName, '\\')) !== false) {
         return ltrim(substr($qualifiedName, 0, $pos), '\\');
     } elseif (Type::isInternalType($qualifiedName)) {
         return Type::getTypePackage($qualifiedName);
     }
     return self::DEFAULT_NAMESPACE;
 }
All Usage Examples Of PDepend\Util\Type::getTypePackage