OutputStreamWriter.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. * $Id: OutputStreamWriter.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. include_once 'phing/system/io/PhingFile.php';
  22. require_once 'phing/system/io/Writer.php';
  23. /**
  24. * Writer class for OutputStream objects.
  25. *
  26. * Unlike the Java counterpart, this class does not (yet) handle
  27. * character set transformations. This will be an important function
  28. * of this class with move to supporting PHP6.
  29. *
  30. * @package phing.system.io
  31. */
  32. class OutputStreamWriter extends Writer {
  33. /**
  34. * @var OutputStream
  35. */
  36. protected $outStream;
  37. /**
  38. * Construct a new OutputStreamWriter.
  39. * @param OutputStream $outStream OutputStream to write to
  40. */
  41. public function __construct(OutputStream $outStream) {
  42. $this->outStream = $outStream;
  43. }
  44. /**
  45. * Close the stream.
  46. */
  47. public function close() {
  48. return $this->outStream->close();
  49. }
  50. /**
  51. * Write char data to stream.
  52. *
  53. * @param unknown_type $buf
  54. * @param unknown_type $off
  55. * @param unknown_type $len
  56. * @return unknown
  57. */
  58. public function write($buf, $off = null, $len = null) {
  59. return $this->outStream->write($buf, $off, $len);
  60. }
  61. /**
  62. * Flush output to the stream.
  63. */
  64. public function flush() {
  65. $this->outStream->flush();
  66. }
  67. /**
  68. * Gets a string representation of attached stream resource.
  69. *
  70. * @return string String representation of output stream
  71. */
  72. public function getResource() {
  73. return $this->outStream->__toString();
  74. }
  75. }