OutputInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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\Output;
  11. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  12. /**
  13. * OutputInterface is the interface implemented by all Output classes.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. *
  17. * @api
  18. */
  19. interface OutputInterface
  20. {
  21. const VERBOSITY_QUIET = 0;
  22. const VERBOSITY_NORMAL = 1;
  23. const VERBOSITY_VERBOSE = 2;
  24. const VERBOSITY_VERY_VERBOSE = 3;
  25. const VERBOSITY_DEBUG = 4;
  26. const OUTPUT_NORMAL = 0;
  27. const OUTPUT_RAW = 1;
  28. const OUTPUT_PLAIN = 2;
  29. /**
  30. * Writes a message to the output.
  31. *
  32. * @param string|array $messages The message as an array of lines or a single string
  33. * @param bool $newline Whether to add a newline
  34. * @param int $type The type of output (one of the OUTPUT constants)
  35. *
  36. * @throws \InvalidArgumentException When unknown output type is given
  37. *
  38. * @api
  39. */
  40. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL);
  41. /**
  42. * Writes a message to the output and adds a newline at the end.
  43. *
  44. * @param string|array $messages The message as an array of lines or a single string
  45. * @param int $type The type of output (one of the OUTPUT constants)
  46. *
  47. * @throws \InvalidArgumentException When unknown output type is given
  48. *
  49. * @api
  50. */
  51. public function writeln($messages, $type = self::OUTPUT_NORMAL);
  52. /**
  53. * Sets the verbosity of the output.
  54. *
  55. * @param int $level The level of verbosity (one of the VERBOSITY constants)
  56. *
  57. * @api
  58. */
  59. public function setVerbosity($level);
  60. /**
  61. * Gets the current verbosity of the output.
  62. *
  63. * @return int The current level of verbosity (one of the VERBOSITY constants)
  64. *
  65. * @api
  66. */
  67. public function getVerbosity();
  68. /**
  69. * Sets the decorated flag.
  70. *
  71. * @param bool $decorated Whether to decorate the messages
  72. *
  73. * @api
  74. */
  75. public function setDecorated($decorated);
  76. /**
  77. * Gets the decorated flag.
  78. *
  79. * @return bool true if the output will decorate messages, false otherwise
  80. *
  81. * @api
  82. */
  83. public function isDecorated();
  84. /**
  85. * Sets output formatter.
  86. *
  87. * @param OutputFormatterInterface $formatter
  88. *
  89. * @api
  90. */
  91. public function setFormatter(OutputFormatterInterface $formatter);
  92. /**
  93. * Returns current output formatter instance.
  94. *
  95. * @return OutputFormatterInterface
  96. *
  97. * @api
  98. */
  99. public function getFormatter();
  100. }