NullOutputFormatter.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\Formatter;
  11. /**
  12. * @author Tien Xuan Vo <tien.xuan.vo@gmail.com>
  13. */
  14. final class NullOutputFormatter implements OutputFormatterInterface
  15. {
  16. private $style;
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function format(?string $message): void
  21. {
  22. // do nothing
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function getStyle(string $name): OutputFormatterStyleInterface
  28. {
  29. if ($this->style) {
  30. return $this->style;
  31. }
  32. // to comply with the interface we must return a OutputFormatterStyleInterface
  33. return $this->style = new NullOutputFormatterStyle();
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function hasStyle(string $name): bool
  39. {
  40. return false;
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function isDecorated(): bool
  46. {
  47. return false;
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function setDecorated(bool $decorated): void
  53. {
  54. // do nothing
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function setStyle(string $name, OutputFormatterStyleInterface $style): void
  60. {
  61. // do nothing
  62. }
  63. }