From 9f98ee25eaffd7edf67a28646aaed1abfc594d98 Mon Sep 17 00:00:00 2001 From: everzet Date: Sun, 25 Sep 2011 15:44:05 +0300 Subject: [PATCH] Enhanced repository interface --- .../Repository/RepositoryInterface.php | 24 +++++++++++ .../WritableRepositoryInterface.php | 42 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/Composer/Repository/WritableRepositoryInterface.php diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php index 49e16690e..9684492da 100644 --- a/src/Composer/Repository/RepositoryInterface.php +++ b/src/Composer/Repository/RepositoryInterface.php @@ -12,10 +12,34 @@ namespace Composer\Repository; +use Composer\Package\PackageInterface; + /** + * Repository interface. + * * @author Nils Adermann + * @author Konstantin Kudryashov */ interface RepositoryInterface extends \Countable { + /** + * Initializes repository (reads file, opens connection). + */ + function initialize(); + + /** + * Checks if specified package registered (installed). + * + * @param PackageInterface $package package instance + * + * @return Boolean + */ + function hasPackage(PackageInterface $package); + + /** + * Returns list of registered packages. + * + * @return array + */ function getPackages(); } diff --git a/src/Composer/Repository/WritableRepositoryInterface.php b/src/Composer/Repository/WritableRepositoryInterface.php new file mode 100644 index 000000000..77291e889 --- /dev/null +++ b/src/Composer/Repository/WritableRepositoryInterface.php @@ -0,0 +1,42 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Repository; + +use Composer\Package\PackageInterface; + +/** + * Writable repository interface. + * + * @author Konstantin Kudryashov + */ +interface WritableRepositoryInterface extends RepositoryInterface +{ + /** + * Writes repository (f.e. to the disc). + */ + function write(); + + /** + * Adds package to the repository. + * + * @param PackageInterface $package package instance + */ + function addPackage(PackageInterface $package); + + /** + * Removes package from the repository. + * + * @param PackageInterface $package package instance + */ + function removePackage(PackageInterface $package); +}