diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 92002e13f..998c659b2 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -12,6 +12,8 @@ namespace Composer; +use Composer\Downloader\DownloaderInterface; +use \Composer\Installer\InstallerInterface; use Composer\Repository\ComposerRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\GitRepository; @@ -33,12 +35,25 @@ class Composer $this->addRepository('Packagist', array('composer' => 'http://packagist.org')); } - public function addDownloader($type, $downloader) + /** + * Add downloader for type + * + * @param string $type + * @param DownloaderInterface $downloader + */ + public function addDownloader($type, DownloaderInterface $downloader) { $type = strtolower($type); $this->downloaders[$type] = $downloader; } + /** + * Get type downloader + * + * @param string $type + * + * @return DownloaderInterface + */ public function getDownloader($type) { $type = strtolower($type); @@ -48,12 +63,25 @@ class Composer return $this->downloaders[$type]; } - public function addInstaller($type, $installer) + /** + * Add installer for type + * + * @param string $type + * @param InstallerInterface $installer + */ + public function addInstaller($type, InstallerInterface $installer) { $type = strtolower($type); $this->installers[$type] = $installer; } + /** + * Get type installer + * + * @param string $type + * + * @return InstallerInterface + */ public function getInstaller($type) { $type = strtolower($type); diff --git a/src/Composer/Downloader/DownloaderInterface.php b/src/Composer/Downloader/DownloaderInterface.php new file mode 100644 index 000000000..b424bba3e --- /dev/null +++ b/src/Composer/Downloader/DownloaderInterface.php @@ -0,0 +1,35 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Downloader; + +use Composer\Package\PackageInterface; + +/** + * Package Downloader + * + * @author Kirill chEbba Chebunin + */ +interface DownloaderInterface +{ + /** + * Download package + * + * @param PackageInterface $package Downloaded package + * @param string $path Download to + * @param string $url Download from + * @param string|null $checksum Package checksum + * + * @throws \UnexpectedValueException + */ + function download(PackageInterface $package, $path, $url, $checksum = null); +} diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index b4193b612..d7a98bed7 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -17,7 +17,7 @@ use Composer\Package\PackageInterface; /** * @author Jordi Boggiano */ -class GitDownloader +class GitDownloader implements DownloaderInterface { protected $clone; diff --git a/src/Composer/Downloader/PearDownloader.php b/src/Composer/Downloader/PearDownloader.php index c36022248..56e45c677 100644 --- a/src/Composer/Downloader/PearDownloader.php +++ b/src/Composer/Downloader/PearDownloader.php @@ -18,7 +18,7 @@ use Composer\Package\PackageInterface; * @author Benjamin Eberlei * @author Jordi Boggiano */ -class PearDownloader +class PearDownloader implements DownloaderInterface { public function download(PackageInterface $package, $path, $url, $checksum = null) { diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index afbe0c687..1c5fa547a 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -17,7 +17,7 @@ use Composer\Package\PackageInterface; /** * @author Jordi Boggiano */ -class ZipDownloader +class ZipDownloader implements DownloaderInterface { public function download(PackageInterface $package, $path, $url, $checksum = null) { diff --git a/src/Composer/Installer/InstallerInterface.php b/src/Composer/Installer/InstallerInterface.php new file mode 100644 index 000000000..6a3ac6fbd --- /dev/null +++ b/src/Composer/Installer/InstallerInterface.php @@ -0,0 +1,33 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Installer; + +use Composer\Downloader\DownloaderInterface; +use Composer\Package\PackageInterface; + +/** + * Package Installer + * + * @author Kirill chEbba Chebunin + */ +interface InstallerInterface +{ + /** + * Install package + * + * @param PackageInterface $package + * @param DownloaderInterface $downloader + * @param string $type + */ + function install(PackageInterface $package, DownloaderInterface $downloader, $type); +} diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 9b91a277e..ad3fd451e 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -12,12 +12,13 @@ namespace Composer\Installer; +use Composer\Downloader\DownloaderInterface; use Composer\Package\PackageInterface; /** * @author Jordi Boggiano */ -class LibraryInstaller +class LibraryInstaller implements InstallerInterface { protected $dir; @@ -26,7 +27,7 @@ class LibraryInstaller $this->dir = $dir; } - public function install(PackageInterface $package, $downloader, $type) + public function install(PackageInterface $package, DownloaderInterface $downloader, $type) { if ($type === 'dist') { $downloader->download($package, $this->dir, $package->getDistUrl(), $package->getDistSha1Checksum());