OutputStyle.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. /**
  23. * @param OutputInterface $output
  24. */
  25. public function __construct(OutputInterface $output)
  26. {
  27. $this->output = $output;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function newLine($count = 1)
  33. {
  34. $this->output->write(str_repeat(PHP_EOL, $count));
  35. }
  36. /**
  37. * @param int $max
  38. *
  39. * @return ProgressBar
  40. */
  41. public function createProgressBar($max = 0)
  42. {
  43. return new ProgressBar($this->output, $max);
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  49. {
  50. $this->output->write($messages, $newline, $type);
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  56. {
  57. $this->output->writeln($messages, $type);
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function setVerbosity($level)
  63. {
  64. $this->output->setVerbosity($level);
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function getVerbosity()
  70. {
  71. return $this->output->getVerbosity();
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function setDecorated($decorated)
  77. {
  78. $this->output->setDecorated($decorated);
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function isDecorated()
  84. {
  85. return $this->output->isDecorated();
  86. }
  87. /**
  88. * {@inheritdoc}
  89. */
  90. public function setFormatter(OutputFormatterInterface $formatter)
  91. {
  92. $this->output->setFormatter($formatter);
  93. }
  94. /**
  95. * {@inheritdoc}
  96. */
  97. public function getFormatter()
  98. {
  99. return $this->output->getFormatter();
  100. }
  101. }