NullOutputFormatter.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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): ?string
  21. {
  22. return null;
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function getStyle(string $name): OutputFormatterStyleInterface
  28. {
  29. // to comply with the interface we must return a OutputFormatterStyleInterface
  30. return $this->style ?? $this->style = new NullOutputFormatterStyle();
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function hasStyle(string $name): bool
  36. {
  37. return false;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function isDecorated(): bool
  43. {
  44. return false;
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function setDecorated(bool $decorated): void
  50. {
  51. // do nothing
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function setStyle(string $name, OutputFormatterStyleInterface $style): void
  57. {
  58. // do nothing
  59. }
  60. }