1<?php 2namespace GuzzleHttp\Stream; 3use GuzzleHttp\Stream\Exception\CannotAttachException; 4 5/** 6 * Does not store any data written to it. 7 */ 8class NullStream implements StreamInterface 9{ 10 public function __toString() 11 { 12 return ''; 13 } 14 15 public function getContents() 16 { 17 return ''; 18 } 19 20 public function close() {} 21 22 public function detach() {} 23 24 public function attach($stream) 25 { 26 throw new CannotAttachException(); 27 } 28 29 public function getSize() 30 { 31 return 0; 32 } 33 34 public function isReadable() 35 { 36 return true; 37 } 38 39 public function isWritable() 40 { 41 return true; 42 } 43 44 public function isSeekable() 45 { 46 return true; 47 } 48 49 public function eof() 50 { 51 return true; 52 } 53 54 public function tell() 55 { 56 return 0; 57 } 58 59 public function seek($offset, $whence = SEEK_SET) 60 { 61 return false; 62 } 63 64 public function read($length) 65 { 66 return false; 67 } 68 69 public function write($string) 70 { 71 return strlen($string); 72 } 73 74 public function getMetadata($key = null) 75 { 76 return $key ? null : []; 77 } 78} 79