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