Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
 
3
namespace Guzzle\Http;
4
 
5
use Guzzle\Stream\Stream;
6
 
7
/**
8
 * Abstract decorator used to wrap entity bodies
9
 */
10
class AbstractEntityBodyDecorator implements EntityBodyInterface
11
{
12
    /** @var EntityBodyInterface Decorated entity body */
13
    protected $body;
14
 
15
    /**
16
     * @param EntityBodyInterface $body Entity body to decorate
17
     */
18
    public function __construct(EntityBodyInterface $body)
19
    {
20
        $this->body = $body;
21
    }
22
 
23
    public function __toString()
24
    {
25
        return (string) $this->body;
26
    }
27
 
28
    /**
29
     * Allow decorators to implement custom methods
30
     *
31
     * @param string $method Missing method name
32
     * @param array  $args   Method arguments
33
     *
34
     * @return mixed
35
     */
36
    public function __call($method, array $args)
37
    {
38
        return call_user_func_array(array($this->body, $method), $args);
39
    }
40
 
41
    public function close()
42
    {
43
        return $this->body->close();
44
    }
45
 
46
    public function setRewindFunction($callable)
47
    {
48
        $this->body->setRewindFunction($callable);
49
 
50
        return $this;
51
    }
52
 
53
    public function rewind()
54
    {
55
        return $this->body->rewind();
56
    }
57
 
58
    public function compress($filter = 'zlib.deflate')
59
    {
60
        return $this->body->compress($filter);
61
    }
62
 
63
    public function uncompress($filter = 'zlib.inflate')
64
    {
65
        return $this->body->uncompress($filter);
66
    }
67
 
68
    public function getContentLength()
69
    {
70
        return $this->getSize();
71
    }
72
 
73
    public function getContentType()
74
    {
75
        return $this->body->getContentType();
76
    }
77
 
78
    public function getContentMd5($rawOutput = false, $base64Encode = false)
79
    {
80
        $hash = Stream::getHash($this, 'md5', $rawOutput);
81
 
82
        return $hash && $base64Encode ? base64_encode($hash) : $hash;
83
    }
84
 
85
    public function getContentEncoding()
86
    {
87
        return $this->body->getContentEncoding();
88
    }
89
 
90
    public function getMetaData($key = null)
91
    {
92
        return $this->body->getMetaData($key);
93
    }
94
 
95
    public function getStream()
96
    {
97
        return $this->body->getStream();
98
    }
99
 
100
    public function setStream($stream, $size = 0)
101
    {
102
        $this->body->setStream($stream, $size);
103
 
104
        return $this;
105
    }
106
 
107
    public function detachStream()
108
    {
109
        $this->body->detachStream();
110
 
111
        return $this;
112
    }
113
 
114
    public function getWrapper()
115
    {
116
        return $this->body->getWrapper();
117
    }
118
 
119
    public function getWrapperData()
120
    {
121
        return $this->body->getWrapperData();
122
    }
123
 
124
    public function getStreamType()
125
    {
126
        return $this->body->getStreamType();
127
    }
128
 
129
    public function getUri()
130
    {
131
        return $this->body->getUri();
132
    }
133
 
134
    public function getSize()
135
    {
136
        return $this->body->getSize();
137
    }
138
 
139
    public function isReadable()
140
    {
141
        return $this->body->isReadable();
142
    }
143
 
144
    public function isRepeatable()
145
    {
146
        return $this->isSeekable() && $this->isReadable();
147
    }
148
 
149
    public function isWritable()
150
    {
151
        return $this->body->isWritable();
152
    }
153
 
154
    public function isConsumed()
155
    {
156
        return $this->body->isConsumed();
157
    }
158
 
159
    /**
160
     * Alias of isConsumed()
161
     * {@inheritdoc}
162
     */
163
    public function feof()
164
    {
165
        return $this->isConsumed();
166
    }
167
 
168
    public function isLocal()
169
    {
170
        return $this->body->isLocal();
171
    }
172
 
173
    public function isSeekable()
174
    {
175
        return $this->body->isSeekable();
176
    }
177
 
178
    public function setSize($size)
179
    {
180
        $this->body->setSize($size);
181
 
182
        return $this;
183
    }
184
 
185
    public function seek($offset, $whence = SEEK_SET)
186
    {
187
        return $this->body->seek($offset, $whence);
188
    }
189
 
190
    public function read($length)
191
    {
192
        return $this->body->read($length);
193
    }
194
 
195
    public function write($string)
196
    {
197
        return $this->body->write($string);
198
    }
199
 
200
    public function readLine($maxLength = null)
201
    {
202
        return $this->body->readLine($maxLength);
203
    }
204
 
205
    public function ftell()
206
    {
207
        return $this->body->ftell();
208
    }
209
 
210
    public function getCustomData($key)
211
    {
212
        return $this->body->getCustomData($key);
213
    }
214
 
215
    public function setCustomData($key, $value)
216
    {
217
        $this->body->setCustomData($key, $value);
218
 
219
        return $this;
220
    }
221
}