~ballot/wordpress/openstack-objectstorage-breaking-insight

« back to all changes in this revision

Viewing changes to src/OpenStack/Common/Transport/Guzzle/MessageAdapter.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/*
 
4
 * (c) Copyright 2014 Rackspace US, Inc.
 
5
 *
 
6
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 
7
 * not use this file except in compliance with the License. You may obtain
 
8
 * a copy of the License at
 
9
 *
 
10
 *      http://www.apache.org/licenses/LICENSE-2.0
 
11
 *
 
12
 * Unless required by applicable law or agreed to in writing, software
 
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
15
 * License for the specific language governing permissions and limitations
 
16
 * under the License.
 
17
 */
 
18
 
 
19
namespace OpenStack\Common\Transport\Guzzle;
 
20
 
 
21
use OpenStack\Common\Transport\MessageInterface;
 
22
use GuzzleHttp\Message\MessageInterface as GuzzleMessageInterface;
 
23
 
 
24
/**
 
25
 * An adapter class which wraps {@see GuzzleHttp\Message\MessageInterface}
 
26
 * objects. Until PSR releases a standardised interface that all projects can
 
27
 * share, we need to adapt the different interfaces.
 
28
 *
 
29
 * As you will notice, most of this adapter is a like-for-like method
 
30
 * translation. Although it seems verbose, it is actually a lot more explicit,
 
31
 * clearer and easier to debug than using magic methods.
 
32
 */
 
33
class MessageAdapter implements MessageInterface
 
34
{
 
35
    /** @var \GuzzleHttp\Message\MessageInterface The Guzzle message being wrapped */
 
36
    protected $message;
 
37
 
 
38
    /**
 
39
     * @param \GuzzleHttp\Message\MessageInterface $guzzleMessage
 
40
     */
 
41
    public function __construct(GuzzleMessageInterface $guzzleMessage)
 
42
    {
 
43
        $this->setMessage($guzzleMessage);
 
44
    }
 
45
 
 
46
    /**
 
47
     * This sets the Guzzle object being wrapped.
 
48
     *
 
49
     * @param \GuzzleHttp\Message\MessageInterface $guzzleMessage The object being wrapped.
 
50
     */
 
51
    public function setMessage(GuzzleMessageInterface $guzzleMessage)
 
52
    {
 
53
        $this->message = $guzzleMessage;
 
54
    }
 
55
 
 
56
    /**
 
57
     * @return \GuzzleHttp\Message\MessageInterface
 
58
     */
 
59
    public function getMessage()
 
60
    {
 
61
        return $this->message;
 
62
    }
 
63
 
 
64
    public function getProtocolVersion()
 
65
    {
 
66
        return $this->message->getProtocolVersion();
 
67
    }
 
68
 
 
69
    public function getBody()
 
70
    {
 
71
        return $this->message->getBody();
 
72
    }
 
73
 
 
74
    public function setBody(/* StreamInterface */ $body = null)
 
75
    {
 
76
        $this->message->setBody($body);
 
77
    }
 
78
 
 
79
    public function getHeaders()
 
80
    {
 
81
        return $this->message->getHeaders();
 
82
    }
 
83
 
 
84
    public function hasHeader($header)
 
85
    {
 
86
        return $this->message->hasHeader($header);
 
87
    }
 
88
 
 
89
    public function getHeader($header, $asArray = false)
 
90
    {
 
91
        return $this->message->getHeader($header, $asArray);
 
92
    }
 
93
 
 
94
    public function setHeader($header, $value)
 
95
    {
 
96
        $this->message->setHeader($header, $value);
 
97
    }
 
98
 
 
99
    public function setHeaders(array $headers)
 
100
    {
 
101
        $this->message->setHeaders($headers);
 
102
    }
 
103
 
 
104
    public function addHeader($header, $value)
 
105
    {
 
106
        $this->message->addHeader($header, $value);
 
107
    }
 
108
 
 
109
    public function addHeaders(array $headers)
 
110
    {
 
111
        $this->message->addHeaders($headers);
 
112
    }
 
113
 
 
114
    public function removeHeader($header)
 
115
    {
 
116
        $this->message->removeHeader($header);
 
117
    }
 
118
}
 
 
b'\\ No newline at end of file'