Ver código fonte

Add type/repositoryType and repositoryUrl package properties

Jordi Boggiano 14 anos atrás
pai
commit
bb5e59e30f

+ 51 - 0
src/Composer/Package/MemoryPackage.php

@@ -19,6 +19,9 @@ namespace Composer\Package;
  */
 class MemoryPackage extends BasePackage
 {
+    protected $type;
+    protected $repositoryType;
+    protected $repositoryUrl;
     protected $releaseType;
     protected $version;
 
@@ -45,6 +48,54 @@ class MemoryPackage extends BasePackage
         $this->version = $version;
     }
 
+    /**
+     * @param string $type
+     */
+    public function setType($type)
+    {
+        $this->type = $type;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function getType()
+    {
+        return $this->type ?: 'library';
+    }
+
+    /**
+     * @param string $type
+     */
+    public function setRepositoryType($type)
+    {
+        $this->repositoryType = $type;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function getRepositoryType()
+    {
+        return $this->repositoryType;
+    }
+
+    /**
+     * @param string $url
+     */
+    public function setRepositoryUrl($url)
+    {
+        $this->repositoryUrl = $url;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function getRepositoryUrl()
+    {
+        return $this->repositoryUrl;
+    }
+
     /**
      * Set the release type
      *

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

@@ -4,6 +4,7 @@
  * This file is part of Composer.
  *
  * (c) Nils Adermann <naderman@naderman.de>
+ *     Jordi Boggiano <j.boggiano@seld.be>
  *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
@@ -45,6 +46,27 @@ interface PackageInterface
      */
     function matches($name, RelationConstraintInterface $constraint);
 
+    /**
+     * Returns the package type of this package, e.g. library
+     *
+     * @return string The package type
+     */
+    function getType();
+
+    /**
+     * Returns the repository type of this package, e.g. git, svn, tar
+     *
+     * @return string The repository type
+     */
+    function getRepositoryType();
+
+    /**
+     * Returns the repository url of this package, e.g. git://github.com/naderman/composer.git
+     *
+     * @return string The repository url
+     */
+    function getRepositoryUrl();
+
     /**
      * Returns the release type of this package, e.g. stable or beta
      *