IOInterface.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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\IO;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  14. use Symfony\Component\Console\Helper\HelperSet;
  15. /**
  16. * The Input/Output helper interface.
  17. *
  18. * @author François Pluchino <francois.pluchino@opendisplay.com>
  19. */
  20. interface IOInterface extends InputInterface, ConsoleOutputInterface
  21. {
  22. /**
  23. * Overwrites a previous message to the output.
  24. *
  25. * @param string|array $messages The message as an array of lines of a single string
  26. * @param integer $size The size of line
  27. * @param Boolean $newline Whether to add a newline or not
  28. * @param integer $type The type of output
  29. */
  30. public function overwrite($messages, $size = 80, $newline = false, $type = 0);
  31. /**
  32. * Overwrites a previous message to the output and adds a newline at the end.
  33. *
  34. * @param string|array $messages The message as an array of lines of a single string
  35. * @param integer $size The size of line
  36. * @param integer $type The type of output
  37. */
  38. public function overwriteln($messages, $size = 80, $type = 0);
  39. /**
  40. * Asks a question to the user.
  41. *
  42. * @param string|array $question The question to ask
  43. * @param string $default The default answer if none is given by the user
  44. *
  45. * @return string The user answer
  46. *
  47. * @throws \RuntimeException If there is no data to read in the input stream
  48. */
  49. public function ask($question, $default = null);
  50. /**
  51. * Asks a confirmation to the user.
  52. *
  53. * The question will be asked until the user answers by nothing, yes, or no.
  54. *
  55. * @param string|array $question The question to ask
  56. * @param Boolean $default The default answer if the user enters nothing
  57. *
  58. * @return Boolean true if the user has confirmed, false otherwise
  59. */
  60. public function askConfirmation($question, $default = true);
  61. /**
  62. * Asks for a value and validates the response.
  63. *
  64. * The validator receives the data to validate. It must return the
  65. * validated data when the data is valid and throw an exception
  66. * otherwise.
  67. *
  68. * @param string|array $question The question to ask
  69. * @param callback $validator A PHP callback
  70. * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
  71. * @param string $default The default answer if none is given by the user
  72. *
  73. * @return mixed
  74. *
  75. * @throws \Exception When any of the validators return an error
  76. */
  77. public function askAndValidate($question, $validator, $attempts = false, $default = null);
  78. /**
  79. * Asks a question to the user and hide the answer.
  80. *
  81. * @param string $question The question to ask
  82. *
  83. * @return string The answer
  84. */
  85. public function askAndHideAnswer($question);
  86. /**
  87. * Get the last username entered.
  88. *
  89. * @return string The username
  90. */
  91. public function getLastUsername();
  92. /**
  93. * Get the last password entered.
  94. *
  95. * @return string The password
  96. */
  97. public function getLastPassword();
  98. /**
  99. * Get all authentification informations entered.
  100. *
  101. * @return array The map of authentification
  102. */
  103. public function getAuthentifications();
  104. /**
  105. * Verify if the repository has a authentification informations.
  106. *
  107. * @param string $repositoryName The unique name of repository
  108. *
  109. * @return boolean
  110. */
  111. public function hasAuthentification($repositoryName);
  112. /**
  113. * Get the username and password of repository.
  114. *
  115. * @param string $repositoryName The unique name of repository
  116. *
  117. * @return array The 'username' and 'password'
  118. */
  119. public function getAuthentification($repositoryName);
  120. /**
  121. * Set the authentification informations for the repository.
  122. *
  123. * @param string $repositoryName The unique name of repository
  124. * @param string $username The username
  125. * @param string $password The password
  126. */
  127. public function setAuthentification($repositoryName, $username, $password = null);
  128. }