NullOutputFormatter.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 NullOutputFormatterStyle $style;
  17. public function format(?string $message): ?string
  18. {
  19. return null;
  20. }
  21. public function getStyle(string $name): OutputFormatterStyleInterface
  22. {
  23. // to comply with the interface we must return a OutputFormatterStyleInterface
  24. return $this->style ??= new NullOutputFormatterStyle();
  25. }
  26. public function hasStyle(string $name): bool
  27. {
  28. return false;
  29. }
  30. public function isDecorated(): bool
  31. {
  32. return false;
  33. }
  34. public function setDecorated(bool $decorated): void
  35. {
  36. // do nothing
  37. }
  38. public function setStyle(string $name, OutputFormatterStyleInterface $style): void
  39. {
  40. // do nothing
  41. }
  42. }