Code Duplication    Length = 18-19 lines in 3 locations

src/Client.php 3 locations

@@ 65-83 (lines=19) @@
62
    /**
63
     * @inheritdoc
64
     */
65
    public function post($resource, $content)
66
    {
67
        $url = $this->baseUrl . $resource;
68
69
        $headers = array(
70
            'Content-Type' => 'application/json',
71
            'Authorization' => $this->auth->getCredential()
72
        );
73
74
        try {
75
            $response = $this->browser->post($url, $headers, json_encode($content));
76
        } catch (\Buzz\Exception\ClientException $e) {
77
            throw new RequestException($e->getMessage());
78
        }
79
80
        $this->checkBrowserResponse();
81
82
        return json_decode($response->getContent(), true);
83
    }
84
85
    /**
86
     * @inheritdoc
@@ 88-105 (lines=18) @@
85
    /**
86
     * @inheritdoc
87
     */
88
    public function put($resource, $content = array())
89
    {
90
        $url = $this->baseUrl . $resource;
91
        $headers = array(
92
            'Content-Type' => 'application/json',
93
            'Authorization' => $this->auth->getCredential()
94
        );
95
96
        try {
97
            $response = $this->browser->put($url, $headers, json_encode($content));
98
        } catch (\Buzz\Exception\ClientException $e) {
99
            throw new RequestException($e->getMessage());
100
        }
101
102
        $this->checkBrowserResponse();
103
104
        return json_decode($response->getContent(), true);
105
    }
106
107
    /**
108
     * @inheritdoc
@@ 110-127 (lines=18) @@
107
    /**
108
     * @inheritdoc
109
     */
110
    public function delete($resource)
111
    {
112
        $url = $this->baseUrl . $resource;
113
114
        $headers = array(
115
            'Authorization' => $this->auth->getCredential()
116
        );
117
118
        try {
119
            $response = $this->browser->delete($url, $headers);
120
        } catch (\Buzz\Exception\ClientException $e) {
121
            throw new RequestException($e->getMessage());
122
        }
123
124
        $this->checkBrowserResponse();
125
126
        return json_decode($response->getContent(), true);
127
    }
128
129
    /**
130
     * Add query string if necessary