Completed
Push — master ( 3b1a80...1321d9 )
by Vincenzo
03:50
created

StreamStub   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 193
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 193
rs 10

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A close() 0 4 1
A detach() 0 4 1
A getSize() 0 4 1
A tell() 0 4 1
A eof() 0 4 1
A isSeekable() 0 4 1
A seek() 0 4 1
A rewind() 0 4 1
A isWritable() 0 4 1
A write() 0 4 1
A isReadable() 0 4 1
A read() 0 4 1
A getContents() 0 4 1
A getMetadata() 0 4 1
1
<?php
2
3
4
namespace Tests\Helpers\Stubs;
5
6
7
use Psr\Http\Message\StreamInterface;
8
9
class StreamStub implements StreamInterface
10
{
11
12
    /**
13
     * Reads all data from the stream into a string, from the beginning to end.
14
     *
15
     * This method MUST attempt to seek to the beginning of the stream before
16
     * reading data and read the stream until the end is reached.
17
     *
18
     * Warning: This could attempt to load a large amount of data into memory.
19
     *
20
     * This method MUST NOT raise an exception in order to conform with PHP's
21
     * string casting operations.
22
     *
23
     * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
24
     * @return string
25
     */
26
    public function __toString()
27
    {
28
        return "";
29
    }
30
31
    /**
32
     * Closes the stream and any underlying resources.
33
     *
34
     * @return void
35
     */
36
    public function close()
37
    {
38
        // TODO: Implement close() method.
39
    }
40
41
    /**
42
     * Separates any underlying resources from the stream.
43
     *
44
     * After the stream has been detached, the stream is in an unusable state.
45
     *
46
     * @return resource|null Underlying PHP stream, if any
47
     */
48
    public function detach()
49
    {
50
        // TODO: Implement detach() method.
51
    }
52
53
    /**
54
     * Get the size of the stream if known.
55
     *
56
     * @return int|null Returns the size in bytes if known, or null if unknown.
57
     */
58
    public function getSize()
59
    {
60
        // TODO: Implement getSize() method.
61
    }
62
63
    /**
64
     * Returns the current position of the file read/write pointer
65
     *
66
     * @return int Position of the file pointer
67
     * @throws \RuntimeException on error.
68
     */
69
    public function tell()
70
    {
71
        // TODO: Implement tell() method.
72
    }
73
74
    /**
75
     * Returns true if the stream is at the end of the stream.
76
     *
77
     * @return bool
78
     */
79
    public function eof()
80
    {
81
        // TODO: Implement eof() method.
82
    }
83
84
    /**
85
     * Returns whether or not the stream is seekable.
86
     *
87
     * @return bool
88
     */
89
    public function isSeekable()
90
    {
91
        // TODO: Implement isSeekable() method.
92
    }
93
94
    /**
95
     * Seek to a position in the stream.
96
     *
97
     * @link http://www.php.net/manual/en/function.fseek.php
98
     * @param int $offset Stream offset
99
     * @param int $whence Specifies how the cursor position will be calculated
100
     *     based on the seek offset. Valid values are identical to the built-in
101
     *     PHP $whence values for `fseek()`.  SEEK_SET: Set position equal to
102
     *     offset bytes SEEK_CUR: Set position to current location plus offset
103
     *     SEEK_END: Set position to end-of-stream plus offset.
104
     * @throws \RuntimeException on failure.
105
     */
106
    public function seek($offset, $whence = SEEK_SET)
107
    {
108
        // TODO: Implement seek() method.
109
    }
110
111
    /**
112
     * Seek to the beginning of the stream.
113
     *
114
     * If the stream is not seekable, this method will raise an exception;
115
     * otherwise, it will perform a seek(0).
116
     *
117
     * @see seek()
118
     * @link http://www.php.net/manual/en/function.fseek.php
119
     * @throws \RuntimeException on failure.
120
     */
121
    public function rewind()
122
    {
123
        // TODO: Implement rewind() method.
124
    }
125
126
    /**
127
     * Returns whether or not the stream is writable.
128
     *
129
     * @return bool
130
     */
131
    public function isWritable()
132
    {
133
        // TODO: Implement isWritable() method.
134
    }
135
136
    /**
137
     * Write data to the stream.
138
     *
139
     * @param string $string The string that is to be written.
140
     * @return int Returns the number of bytes written to the stream.
141
     * @throws \RuntimeException on failure.
142
     */
143
    public function write($string)
144
    {
145
        return 1;
146
    }
147
148
    /**
149
     * Returns whether or not the stream is readable.
150
     *
151
     * @return bool
152
     */
153
    public function isReadable()
154
    {
155
        // TODO: Implement isReadable() method.
156
    }
157
158
    /**
159
     * Read data from the stream.
160
     *
161
     * @param int $length Read up to $length bytes from the object and return
162
     *     them. Fewer than $length bytes may be returned if underlying stream
163
     *     call returns fewer bytes.
164
     * @return string Returns the data read from the stream, or an empty string
165
     *     if no bytes are available.
166
     * @throws \RuntimeException if an error occurs.
167
     */
168
    public function read($length)
169
    {
170
        // TODO: Implement read() method.
171
    }
172
173
    /**
174
     * Returns the remaining contents in a string
175
     *
176
     * @return string
177
     * @throws \RuntimeException if unable to read or an error occurs while
178
     *     reading.
179
     */
180
    public function getContents()
181
    {
182
        // TODO: Implement getContents() method.
183
    }
184
185
    /**
186
     * Get stream metadata as an associative array or retrieve a specific key.
187
     *
188
     * The keys returned are identical to the keys returned from PHP's
189
     * stream_get_meta_data() function.
190
     *
191
     * @link http://php.net/manual/en/function.stream-get-meta-data.php
192
     * @param string $key Specific metadata to retrieve.
193
     * @return array|mixed|null Returns an associative array if no key is
194
     *     provided. Returns a specific key value if a key is provided and the
195
     *     value is found, or null if the key is not found.
196
     */
197
    public function getMetadata($key = null)
198
    {
199
        // TODO: Implement getMetadata() method.
200
    }
201
}