RepositoryInterface.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. use Composer\Semver\Constraint\ConstraintInterface;
  14. /**
  15. * Repository interface.
  16. *
  17. * @author Nils Adermann <naderman@naderman.de>
  18. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  19. * @author Jordi Boggiano <j.boggiano@seld.be>
  20. */
  21. interface RepositoryInterface extends \Countable
  22. {
  23. const SEARCH_FULLTEXT = 0;
  24. const SEARCH_NAME = 1;
  25. /**
  26. * Checks if specified package registered (installed).
  27. *
  28. * @param PackageInterface $package package instance
  29. *
  30. * @return bool
  31. */
  32. public function hasPackage(PackageInterface $package);
  33. /**
  34. * Searches for the first match of a package by name and version.
  35. *
  36. * @param string $name package name
  37. * @param string|ConstraintInterface $constraint package version or version constraint to match against
  38. *
  39. * @return PackageInterface|null
  40. */
  41. public function findPackage($name, $constraint);
  42. /**
  43. * Searches for all packages matching a name and optionally a version.
  44. *
  45. * @param string $name package name
  46. * @param string|ConstraintInterface $constraint package version or version constraint to match against
  47. *
  48. * @return PackageInterface[]
  49. */
  50. public function findPackages($name, $constraint = null);
  51. // TODO this should really not be in this generic interface anymore
  52. /**
  53. * Returns list of registered packages.
  54. *
  55. * @return PackageInterface[]
  56. */
  57. public function getPackages();
  58. /**
  59. * Returns list of registered packages with the supplied name
  60. *
  61. * @param ConstraintInterface[] $packageNameMap package names pointing to constraints
  62. * @param $isPackageAcceptableCallable
  63. * @return array [namesFound => string[], packages => PackageInterface[]]
  64. */
  65. public function loadPackages(array $packageNameMap, $isPackageAcceptableCallable);
  66. /**
  67. * Searches the repository for packages containing the query
  68. *
  69. * @param string $query search query
  70. * @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only
  71. * @param string $type The type of package to search for. Defaults to all types of packages
  72. *
  73. * @return array[] an array of array('name' => '...', 'description' => '...')
  74. */
  75. public function search($query, $mode = 0, $type = null);
  76. }