You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 line
2.9KB

  1. <?php
  2. /*
  3. * This file is part of the Fxp Composer Asset Plugin package.
  4. *
  5. * (c) François Pluchino <francois.pluchino@gmail.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 Fxp\Composer\AssetPlugin\Tests\Fixtures\IO;
  11. use Composer\IO\BaseIO;
  12. /**
  13. * Mock of IO.
  14. *
  15. * @author François Pluchino <francois.pluchino@gmail.com>
  16. */
  17. class MockIO extends BaseIO
  18. {
  19. /**
  20. * @var bool
  21. */
  22. protected $verbose;
  23. /**
  24. * @var array
  25. */
  26. protected $traces;
  27. /**
  28. * Constructor.
  29. *
  30. * @param bool $verbose
  31. */
  32. public function __construct($verbose)
  33. {
  34. $this->verbose = $verbose;
  35. $this->traces = array();
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function isInteractive()
  41. {
  42. return false;
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function isVerbose()
  48. {
  49. return $this->verbose;
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function isVeryVerbose()
  55. {
  56. return $this->verbose;
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function isDebug()
  62. {
  63. return false;
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function isDecorated()
  69. {
  70. return false;
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function write($messages, $newline = true)
  76. {
  77. $pos = max(count($this->traces) - 1, 0);
  78. if (isset($this->traces[$pos])) {
  79. $messages = $this->traces[$pos].$messages;
  80. }
  81. $this->traces[$pos] = $messages;
  82. if ($newline) {
  83. $this->traces[] = '';
  84. }
  85. }
  86. /**
  87. * {@inheritdoc}
  88. */
  89. public function writeError($messages, $newline = true)
  90. {
  91. $this->write($messages, $newline);
  92. }
  93. /**
  94. * {@inheritdoc}
  95. */
  96. public function overwrite($messages, $newline = true, $size = 80)
  97. {
  98. $pos = max(count($this->traces) - 1, 0);
  99. $this->traces[$pos] = $messages;
  100. if ($newline) {
  101. $this->traces[] = '';
  102. }
  103. }
  104. public function overwriteError($messages, $newline = true, $size = null)
  105. {
  106. $this->overwrite($messages, $newline, $size);
  107. }
  108. /**
  109. * {@inheritdoc}
  110. */
  111. public function ask($question, $default = null)
  112. {
  113. return $default;
  114. }
  115. /**
  116. * {@inheritdoc}
  117. */
  118. public function askConfirmation($question, $default = true)
  119. {
  120. return $default;
  121. }
  122. /**
  123. * {@inheritdoc}
  124. */
  125. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  126. {
  127. return $default;
  128. }
  129. /**
  130. * {@inheritdoc}
  131. */
  132. public function askAndHideAnswer($question)
  133. {
  134. return;
  135. }
  136. /**
  137. * Gets the taces.
  138. *
  139. * @return array
  140. */
  141. public function getTraces()
  142. {
  143. return $this->traces;
  144. }
  145. }