OutputStyle.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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\Style;
  11. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  12. use Symfony\Component\Console\Helper\ProgressBar;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. /**
  15. * Decorates output to add console style guide helpers.
  16. *
  17. * @author Kevin Bond <kevinbond@gmail.com>
  18. */
  19. abstract class OutputStyle implements OutputInterface, StyleInterface
  20. {
  21. private $output;
  22. public function __construct(OutputInterface $output)
  23. {
  24. $this->output = $output;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function newLine($count = 1)
  30. {
  31. $this->output->write(str_repeat(PHP_EOL, $count));
  32. }
  33. /**
  34. * @param int $max
  35. *
  36. * @return ProgressBar
  37. */
  38. public function createProgressBar($max = 0)
  39. {
  40. return new ProgressBar($this->output, $max);
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  46. {
  47. $this->output->write($messages, $newline, $type);
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  53. {
  54. $this->output->writeln($messages, $type);
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function setVerbosity($level)
  60. {
  61. $this->output->setVerbosity($level);
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public function getVerbosity()
  67. {
  68. return $this->output->getVerbosity();
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function setDecorated($decorated)
  74. {
  75. $this->output->setDecorated($decorated);
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function isDecorated()
  81. {
  82. return $this->output->isDecorated();
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function setFormatter(OutputFormatterInterface $formatter)
  88. {
  89. $this->output->setFormatter($formatter);
  90. }
  91. /**
  92. * {@inheritdoc}
  93. */
  94. public function getFormatter()
  95. {
  96. return $this->output->getFormatter();
  97. }
  98. }