IOInterface.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 Composer\Config;
  13. /**
  14. * The Input/Output helper interface.
  15. *
  16. * @author François Pluchino <francois.pluchino@opendisplay.com>
  17. */
  18. interface IOInterface
  19. {
  20. /**
  21. * Is this input means interactive?
  22. *
  23. * @return bool
  24. */
  25. public function isInteractive();
  26. /**
  27. * Is this output verbose?
  28. *
  29. * @return bool
  30. */
  31. public function isVerbose();
  32. /**
  33. * Is the output very verbose?
  34. *
  35. * @return bool
  36. */
  37. public function isVeryVerbose();
  38. /**
  39. * Is the output in debug verbosity?
  40. *
  41. * @return bool
  42. */
  43. public function isDebug();
  44. /**
  45. * Is this output decorated?
  46. *
  47. * @return bool
  48. */
  49. public function isDecorated();
  50. /**
  51. * Writes a message to the output.
  52. *
  53. * @param string|array $messages The message as an array of lines or a single string
  54. * @param bool $newline Whether to add a newline or not
  55. */
  56. public function write($messages, $newline = true);
  57. /**
  58. * Overwrites a previous message to the output.
  59. *
  60. * @param string|array $messages The message as an array of lines or a single string
  61. * @param bool $newline Whether to add a newline or not
  62. * @param integer $size The size of line
  63. */
  64. public function overwrite($messages, $newline = true, $size = null);
  65. /**
  66. * Asks a question to the user.
  67. *
  68. * @param string|array $question The question to ask
  69. * @param string $default The default answer if none is given by the user
  70. *
  71. * @return string The user answer
  72. *
  73. * @throws \RuntimeException If there is no data to read in the input stream
  74. */
  75. public function ask($question, $default = null);
  76. /**
  77. * Asks a confirmation to the user.
  78. *
  79. * The question will be asked until the user answers by nothing, yes, or no.
  80. *
  81. * @param string|array $question The question to ask
  82. * @param bool $default The default answer if the user enters nothing
  83. *
  84. * @return bool true if the user has confirmed, false otherwise
  85. */
  86. public function askConfirmation($question, $default = true);
  87. /**
  88. * Asks for a value and validates the response.
  89. *
  90. * The validator receives the data to validate. It must return the
  91. * validated data when the data is valid and throw an exception
  92. * otherwise.
  93. *
  94. * @param string|array $question The question to ask
  95. * @param callback $validator A PHP callback
  96. * @param bool|integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
  97. * @param string $default The default answer if none is given by the user
  98. *
  99. * @return mixed
  100. *
  101. * @throws \Exception When any of the validators return an error
  102. */
  103. public function askAndValidate($question, $validator, $attempts = false, $default = null);
  104. /**
  105. * Asks a question to the user and hide the answer.
  106. *
  107. * @param string $question The question to ask
  108. *
  109. * @return string The answer
  110. */
  111. public function askAndHideAnswer($question);
  112. /**
  113. * Get all authentication information entered.
  114. *
  115. * @return array The map of authentication data
  116. */
  117. public function getAuthentications();
  118. /**
  119. * Verify if the repository has a authentication information.
  120. *
  121. * @param string $repositoryName The unique name of repository
  122. *
  123. * @return boolean
  124. */
  125. public function hasAuthentication($repositoryName);
  126. /**
  127. * Get the username and password of repository.
  128. *
  129. * @param string $repositoryName The unique name of repository
  130. *
  131. * @return array The 'username' and 'password'
  132. */
  133. public function getAuthentication($repositoryName);
  134. /**
  135. * Set the authentication information for the repository.
  136. *
  137. * @param string $repositoryName The unique name of repository
  138. * @param string $username The username
  139. * @param string $password The password
  140. */
  141. public function setAuthentication($repositoryName, $username, $password = null);
  142. /**
  143. * Loads authentications from a config instance
  144. *
  145. * @param Config $config
  146. */
  147. public function loadConfiguration(Config $config);
  148. /**
  149. * Get the value of an input option
  150. *
  151. * @param string $optionName The name of the option whose value is to be retrieved
  152. *
  153. * @return mixed
  154. */
  155. public function getInputOption($optionName);
  156. /**
  157. * Get the value of an input argument
  158. *
  159. * @param string $argumentName The name of the argument whose value is to be retrieved
  160. *
  161. * @return mixed
  162. */
  163. public function getInputArgument($argumentName);
  164. }