InputInterface.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. *
  34. * @return bool true if the value is contained in the raw parameters
  35. */
  36. public function hasParameterOption($values);
  37. /**
  38. * Returns the value of a raw option (not parsed).
  39. *
  40. * This method is to be used to introspect the input parameters
  41. * before they have been validated. It must be used carefully.
  42. *
  43. * @param string|array $values The value(s) to look for in the raw parameters (can be an array)
  44. * @param mixed $default The default value to return if no result is found
  45. *
  46. * @return mixed The option value
  47. */
  48. public function getParameterOption($values, $default = false);
  49. /**
  50. * Binds the current Input instance with the given arguments and options.
  51. *
  52. * @param InputDefinition $definition A InputDefinition instance
  53. */
  54. public function bind(InputDefinition $definition);
  55. /**
  56. * Validates the input.
  57. *
  58. * @throws RuntimeException When not enough arguments are given
  59. */
  60. public function validate();
  61. /**
  62. * Returns all the given arguments merged with the default values.
  63. *
  64. * @return array
  65. */
  66. public function getArguments();
  67. /**
  68. * Returns the argument value for a given argument name.
  69. *
  70. * @param string $name The argument name
  71. *
  72. * @return mixed The argument value
  73. *
  74. * @throws InvalidArgumentException When argument given doesn't exist
  75. */
  76. public function getArgument($name);
  77. /**
  78. * Sets an argument value by name.
  79. *
  80. * @param string $name The argument name
  81. * @param string $value The argument value
  82. *
  83. * @throws InvalidArgumentException When argument given doesn't exist
  84. */
  85. public function setArgument($name, $value);
  86. /**
  87. * Returns true if an InputArgument object exists by name or position.
  88. *
  89. * @param string|int $name The InputArgument name or position
  90. *
  91. * @return bool true if the InputArgument object exists, false otherwise
  92. */
  93. public function hasArgument($name);
  94. /**
  95. * Returns all the given options merged with the default values.
  96. *
  97. * @return array
  98. */
  99. public function getOptions();
  100. /**
  101. * Returns the option value for a given option name.
  102. *
  103. * @param string $name The option name
  104. *
  105. * @return mixed The option value
  106. *
  107. * @throws InvalidArgumentException When option given doesn't exist
  108. */
  109. public function getOption($name);
  110. /**
  111. * Sets an option value by name.
  112. *
  113. * @param string $name The option name
  114. * @param string|bool $value The option value
  115. *
  116. * @throws InvalidArgumentException When option given doesn't exist
  117. */
  118. public function setOption($name, $value);
  119. /**
  120. * Returns true if an InputOption object exists by name.
  121. *
  122. * @param string $name The InputOption name
  123. *
  124. * @return bool true if the InputOption object exists, false otherwise
  125. */
  126. public function hasOption($name);
  127. /**
  128. * Is this input means interactive?
  129. *
  130. * @return bool
  131. */
  132. public function isInteractive();
  133. /**
  134. * Sets the input interactivity.
  135. *
  136. * @param bool $interactive If the input should be interactive
  137. */
  138. public function setInteractive($interactive);
  139. }