RepositoryInterface.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * Checks if specified package name is registered (installed).
  34. *
  35. * @param string $package_name package name (vendor/project)
  36. *
  37. * @return bool
  38. */
  39. public function hasPackageName(string $packageName);
  40. /**
  41. * Searches for the first match of a package by name and version.
  42. *
  43. * @param string $name package name
  44. * @param string|\Composer\Semver\Constraint\ConstraintInterface $constraint package version or version constraint to match against
  45. *
  46. * @return PackageInterface|null
  47. */
  48. public function findPackage($name, $constraint);
  49. /**
  50. * Searches for all packages matching a name and optionally a version.
  51. *
  52. * @param string $name package name
  53. * @param string|\Composer\Semver\Constraint\ConstraintInterface $constraint package version or version constraint to match against
  54. *
  55. * @return PackageInterface[]
  56. */
  57. public function findPackages($name, $constraint = null);
  58. /**
  59. * Returns list of registered packages.
  60. *
  61. * @return PackageInterface[]
  62. */
  63. public function getPackages();
  64. /**
  65. * Searches the repository for packages containing the query
  66. *
  67. * @param string $query search query
  68. * @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only
  69. *
  70. * @return array[] an array of array('name' => '...', 'description' => '...')
  71. */
  72. public function search($query, $mode = 0);
  73. }