Browse Source

Enhanced PackageInterface and BasePackage with getUniqueName() method, which provides name-version-releaseType string (used in installer registry)

everzet 13 years ago
parent
commit
69f1de9986
2 changed files with 18 additions and 1 deletions
  1. 11 1
      src/Composer/Package/BasePackage.php
  2. 7 0
      src/Composer/Package/PackageInterface.php

+ 11 - 1
src/Composer/Package/BasePackage.php

@@ -134,6 +134,16 @@ abstract class BasePackage implements PackageInterface
         $this->repository = $repository;
     }
 
+    /**
+     * Returns package unique name, constructed from name, version and release type.
+     *
+     * @return string
+     */
+    public function getUniqueName()
+    {
+        return $this->getName().'-'.$this->getVersion().'-'.$this->getReleaseType();
+    }
+
     /**
      * Converts the package into a readable and unique string
      *
@@ -141,6 +151,6 @@ abstract class BasePackage implements PackageInterface
      */
     public function __toString()
     {
-        return $this->getName().'-'.$this->getVersion().'-'.$this->getReleaseType();
+        return $this->getUniqueName();
     }
 }

+ 7 - 0
src/Composer/Package/PackageInterface.php

@@ -200,6 +200,13 @@ interface PackageInterface
      */
     function getRepository();
 
+    /**
+     * Returns package unique name, constructed from name, version and release type.
+     *
+     * @return string
+     */
+    function getUniqueName();
+
     /**
      * Converts the package into a readable and unique string
      *