VcsDriverInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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\Vcs;
  12. use Composer\Config;
  13. use Composer\IO\IOInterface;
  14. /**
  15. * @author Jordi Boggiano <j.boggiano@seld.be>
  16. */
  17. interface VcsDriverInterface
  18. {
  19. /**
  20. * Initializes the driver (git clone, svn checkout, fetch info etc)
  21. */
  22. public function initialize();
  23. /**
  24. * Return the composer.json file information
  25. *
  26. * @param string $identifier Any identifier to a specific branch/tag/commit
  27. * @return array containing all infos from the composer.json file
  28. */
  29. public function getComposerInformation($identifier);
  30. /**
  31. * Return the content of $file or null if the file does not exist.
  32. *
  33. * @param string $file
  34. * @param string $identifier
  35. * @return string|null
  36. */
  37. public function getFileContent($file, $identifier);
  38. /**
  39. * Get the changedate for $identifier.
  40. *
  41. * @param string $identifier
  42. * @return \DateTime|null
  43. */
  44. public function getChangeDate($identifier);
  45. /**
  46. * Return the root identifier (trunk, master, default/tip ..)
  47. *
  48. * @return string Identifier
  49. */
  50. public function getRootIdentifier();
  51. /**
  52. * Return list of branches in the repository
  53. *
  54. * @return array Branch names as keys, identifiers as values
  55. */
  56. public function getBranches();
  57. /**
  58. * Return list of tags in the repository
  59. *
  60. * @return array Tag names as keys, identifiers as values
  61. */
  62. public function getTags();
  63. /**
  64. * @param string $identifier Any identifier to a specific branch/tag/commit
  65. * @return array|null With type, url reference and shasum keys.
  66. */
  67. public function getDist($identifier);
  68. /**
  69. * @param string $identifier Any identifier to a specific branch/tag/commit
  70. * @return array With type, url and reference keys.
  71. */
  72. public function getSource($identifier);
  73. /**
  74. * Return the URL of the repository
  75. *
  76. * @return string
  77. */
  78. public function getUrl();
  79. /**
  80. * Return true if the repository has a composer file for a given identifier,
  81. * false otherwise.
  82. *
  83. * @param string $identifier Any identifier to a specific branch/tag/commit
  84. * @return bool Whether the repository has a composer file for a given identifier.
  85. */
  86. public function hasComposerFile($identifier);
  87. /**
  88. * Performs any cleanup necessary as the driver is not longer needed
  89. */
  90. public function cleanup();
  91. /**
  92. * Checks if this driver can handle a given url
  93. *
  94. * @param IOInterface $io IO instance
  95. * @param Config $config current $config
  96. * @param string $url URL to validate/check
  97. * @param bool $deep unless true, only shallow checks (url matching typically) should be done
  98. * @return bool
  99. */
  100. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  101. }