RepositoryInterface.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Repository;
  12. use Composer\Package\PackageInterface;
  13. /**
  14. * Repository interface.
  15. *
  16. * @author Nils Adermann <naderman@naderman.de>
  17. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  18. * @author Jordi Boggiano <j.boggiano@seld.be>
  19. */
  20. interface RepositoryInterface extends \Countable
  21. {
  22. const SEARCH_FULLTEXT = 0;
  23. const SEARCH_NAME = 1;
  24. /**
  25. * Checks if specified package registered (installed).
  26. *
  27. * @param PackageInterface $package package instance
  28. *
  29. * @return bool
  30. */
  31. public function hasPackage(PackageInterface $package);
  32. /**
  33. * Searches for the first match of a package by name and version.
  34. *
  35. * @param string $name package name
  36. * @param string|\Composer\Semver\Constraint\ConstraintInterface $constraint package version or version constraint to match against
  37. *
  38. * @return PackageInterface|null
  39. */
  40. public function findPackage($name, $constraint);
  41. /**
  42. * Searches for all packages matching a name and optionally a version.
  43. *
  44. * @param string $name package name
  45. * @param string|\Composer\Semver\Constraint\ConstraintInterface $constraint package version or version constraint to match against
  46. *
  47. * @return PackageInterface[]
  48. */
  49. public function findPackages($name, $constraint = null);
  50. /**
  51. * Returns list of registered packages.
  52. *
  53. * @return PackageInterface[]
  54. */
  55. public function getPackages();
  56. /**
  57. * Searches the repository for packages containing the query
  58. *
  59. * @param string $query search query
  60. * @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only
  61. *
  62. * @return array[] an array of array('name' => '...', 'description' => '...')
  63. */
  64. public function search($query, $mode = 0);
  65. }