InputInterface.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. /**
  12. * InputInterface is the interface implemented by all input classes.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. interface InputInterface
  17. {
  18. /**
  19. * Returns the first argument from the raw parameters (not parsed).
  20. *
  21. * @return string The value of the first argument or null otherwise
  22. */
  23. public function getFirstArgument();
  24. /**
  25. * Returns true if the raw parameters (not parsed) contain a value.
  26. *
  27. * This method is to be used to introspect the input parameters
  28. * before they have been validated. It must be used carefully.
  29. *
  30. * @param string|array $values The values to look for in the raw parameters (can be an array)
  31. *
  32. * @return Boolean true if the value is contained in the raw parameters
  33. */
  34. public function hasParameterOption($values);
  35. /**
  36. * Returns the value of a raw option (not parsed).
  37. *
  38. * This method is to be used to introspect the input parameters
  39. * before they have been validated. It must be used carefully.
  40. *
  41. * @param string|array $values The value(s) to look for in the raw parameters (can be an array)
  42. * @param mixed $default The default value to return if no result is found
  43. *
  44. * @return mixed The option value
  45. */
  46. public function getParameterOption($values, $default = false);
  47. /**
  48. * Binds the current Input instance with the given arguments and options.
  49. *
  50. * @param InputDefinition $definition A InputDefinition instance
  51. */
  52. public function bind(InputDefinition $definition);
  53. /**
  54. * Validates if arguments given are correct.
  55. *
  56. * Throws an exception when not enough arguments are given.
  57. *
  58. * @throws \RuntimeException
  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. * Gets argument by name.
  69. *
  70. * @param string $name The name of the argument
  71. *
  72. * @return mixed
  73. */
  74. public function getArgument($name);
  75. /**
  76. * Sets an argument value by name.
  77. *
  78. * @param string $name The argument name
  79. * @param string $value The argument value
  80. *
  81. * @throws \InvalidArgumentException When argument given doesn't exist
  82. */
  83. public function setArgument($name, $value);
  84. /**
  85. * Returns true if an InputArgument object exists by name or position.
  86. *
  87. * @param string|integer $name The InputArgument name or position
  88. *
  89. * @return Boolean true if the InputArgument object exists, false otherwise
  90. */
  91. public function hasArgument($name);
  92. /**
  93. * Returns all the given options merged with the default values.
  94. *
  95. * @return array
  96. */
  97. public function getOptions();
  98. /**
  99. * Gets an option by name.
  100. *
  101. * @param string $name The name of the option
  102. *
  103. * @return mixed
  104. */
  105. public function getOption($name);
  106. /**
  107. * Sets an option value by name.
  108. *
  109. * @param string $name The option name
  110. * @param string $value The option value
  111. *
  112. * @throws \InvalidArgumentException When option given doesn't exist
  113. */
  114. public function setOption($name, $value);
  115. /**
  116. * Returns true if an InputOption object exists by name.
  117. *
  118. * @param string $name The InputOption name
  119. *
  120. * @return Boolean true if the InputOption object exists, false otherwise
  121. */
  122. public function hasOption($name);
  123. /**
  124. * Is this input means interactive?
  125. *
  126. * @return Boolean
  127. */
  128. public function isInteractive();
  129. /**
  130. * Sets the input interactivity.
  131. *
  132. * @param Boolean $interactive If the input should be interactive
  133. */
  134. public function setInteractive($interactive);
  135. }