InputInterface.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Input;
  11. use Symfony\Component\Console\Exception\InvalidArgumentException;
  12. use Symfony\Component\Console\Exception\RuntimeException;
  13. /**
  14. * InputInterface is the interface implemented by all input classes.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. interface InputInterface
  19. {
  20. /**
  21. * Returns the first argument from the raw parameters (not parsed).
  22. *
  23. * @return string The value of the first argument or null otherwise
  24. */
  25. public function getFirstArgument();
  26. /**
  27. * Returns true if the raw parameters (not parsed) contain a value.
  28. *
  29. * This method is to be used to introspect the input parameters
  30. * before they have been validated. It must be used carefully.
  31. *
  32. * @param string|array $values The values to look for in the raw parameters (can be an array)
  33. * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
  34. *
  35. * @return bool true if the value is contained in the raw parameters
  36. */
  37. public function hasParameterOption($values, $onlyParams = false);
  38. /**
  39. * Returns the value of a raw option (not parsed).
  40. *
  41. * This method is to be used to introspect the input parameters
  42. * before they have been validated. It must be used carefully.
  43. *
  44. * @param string|array $values The value(s) to look for in the raw parameters (can be an array)
  45. * @param mixed $default The default value to return if no result is found
  46. * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
  47. *
  48. * @return mixed The option value
  49. */
  50. public function getParameterOption($values, $default = false, $onlyParams = false);
  51. /**
  52. * Binds the current Input instance with the given arguments and options.
  53. *
  54. * @param InputDefinition $definition A InputDefinition instance
  55. */
  56. public function bind(InputDefinition $definition);
  57. /**
  58. * Validates the input.
  59. *
  60. * @throws RuntimeException When not enough arguments are given
  61. */
  62. public function validate();
  63. /**
  64. * Returns all the given arguments merged with the default values.
  65. *
  66. * @return array
  67. */
  68. public function getArguments();
  69. /**
  70. * Returns the argument value for a given argument name.
  71. *
  72. * @param string $name The argument name
  73. *
  74. * @return mixed The argument value
  75. *
  76. * @throws InvalidArgumentException When argument given doesn't exist
  77. */
  78. public function getArgument($name);
  79. /**
  80. * Sets an argument value by name.
  81. *
  82. * @param string $name The argument name
  83. * @param string $value The argument value
  84. *
  85. * @throws InvalidArgumentException When argument given doesn't exist
  86. */
  87. public function setArgument($name, $value);
  88. /**
  89. * Returns true if an InputArgument object exists by name or position.
  90. *
  91. * @param string|int $name The InputArgument name or position
  92. *
  93. * @return bool true if the InputArgument object exists, false otherwise
  94. */
  95. public function hasArgument($name);
  96. /**
  97. * Returns all the given options merged with the default values.
  98. *
  99. * @return array
  100. */
  101. public function getOptions();
  102. /**
  103. * Returns the option value for a given option name.
  104. *
  105. * @param string $name The option name
  106. *
  107. * @return mixed The option value
  108. *
  109. * @throws InvalidArgumentException When option given doesn't exist
  110. */
  111. public function getOption($name);
  112. /**
  113. * Sets an option value by name.
  114. *
  115. * @param string $name The option name
  116. * @param string|bool $value The option value
  117. *
  118. * @throws InvalidArgumentException When option given doesn't exist
  119. */
  120. public function setOption($name, $value);
  121. /**
  122. * Returns true if an InputOption object exists by name.
  123. *
  124. * @param string $name The InputOption name
  125. *
  126. * @return bool true if the InputOption object exists, false otherwise
  127. */
  128. public function hasOption($name);
  129. /**
  130. * Is this input means interactive?
  131. *
  132. * @return bool
  133. */
  134. public function isInteractive();
  135. /**
  136. * Sets the input interactivity.
  137. *
  138. * @param bool $interactive If the input should be interactive
  139. */
  140. public function setInteractive($interactive);
  141. }