NullOutput.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. private $formatter;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function setFormatter(OutputFormatterInterface $formatter)
  28. {
  29. // do nothing
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function getFormatter()
  35. {
  36. if ($this->formatter) {
  37. return $this->formatter;
  38. }
  39. // to comply with the interface we must return a OutputFormatterInterface
  40. return $this->formatter = new NullOutputFormatter();
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function setDecorated(bool $decorated)
  46. {
  47. // do nothing
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function isDecorated()
  53. {
  54. return false;
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function setVerbosity(int $level)
  60. {
  61. // do nothing
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public function getVerbosity()
  67. {
  68. return self::VERBOSITY_QUIET;
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function isQuiet()
  74. {
  75. return true;
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function isVerbose()
  81. {
  82. return false;
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function isVeryVerbose()
  88. {
  89. return false;
  90. }
  91. /**
  92. * {@inheritdoc}
  93. */
  94. public function isDebug()
  95. {
  96. return false;
  97. }
  98. /**
  99. * {@inheritdoc}
  100. */
  101. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  102. {
  103. // do nothing
  104. }
  105. /**
  106. * {@inheritdoc}
  107. */
  108. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  109. {
  110. // do nothing
  111. }
  112. }