NullOutput.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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\NullOutputFormatter;
  12. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  13. /**
  14. * NullOutput suppresses all output.
  15. *
  16. * $output = new NullOutput();
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. * @author Tobias Schultze <http://tobion.de>
  20. */
  21. class NullOutput implements OutputInterface
  22. {
  23. /**
  24. * @var \Symfony\Component\Console\Formatter\NullOutputFormatter
  25. */
  26. private $formatter;
  27. /**
  28. * @return void
  29. * @param \Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter
  30. */
  31. public function setFormatter($formatter)
  32. {
  33. // do nothing
  34. }
  35. public function getFormatter()
  36. {
  37. // to comply with the interface we must return a OutputFormatterInterface
  38. return $this->formatter = $this->formatter ?? new NullOutputFormatter();
  39. }
  40. /**
  41. * @return void
  42. * @param bool $decorated
  43. */
  44. public function setDecorated($decorated)
  45. {
  46. // do nothing
  47. }
  48. public function isDecorated()
  49. {
  50. return false;
  51. }
  52. /**
  53. * @return void
  54. * @param int $level
  55. */
  56. public function setVerbosity($level)
  57. {
  58. // do nothing
  59. }
  60. public function getVerbosity()
  61. {
  62. return self::VERBOSITY_QUIET;
  63. }
  64. public function isQuiet()
  65. {
  66. return true;
  67. }
  68. public function isVerbose()
  69. {
  70. return false;
  71. }
  72. public function isVeryVerbose()
  73. {
  74. return false;
  75. }
  76. public function isDebug()
  77. {
  78. return false;
  79. }
  80. /**
  81. * @return void
  82. * @param string|mixed[] $messages
  83. * @param int $options
  84. */
  85. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  86. {
  87. // do nothing
  88. }
  89. /**
  90. * @return void
  91. * @param string|mixed[] $messages
  92. * @param bool $newline
  93. * @param int $options
  94. */
  95. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  96. {
  97. // do nothing
  98. }
  99. }