Code Duplication    Length = 20-22 lines in 2 locations

source/Spiral/Storage/Servers/AmazonServer.php 2 locations

@@ 160-181 (lines=22) @@
157
    /**
158
     * {@inheritdoc}
159
     */
160
    public function rename(BucketInterface $bucket, $oldname, $newname)
161
    {
162
        try {
163
            $request = $this->buildRequest('PUT', $bucket, $newname, [], [
164
                'Acl'         => $bucket->getOption('public') ? 'public-read' : 'private',
165
                'Copy-Source' => $this->buildUri($bucket, $oldname)->getPath()
166
            ]);
167
168
            $this->client->send($request);
169
        } catch (ClientException $exception) {
170
            if ($exception->getCode() != 404) {
171
                //Some authorization or other error
172
                throw $exception;
173
            }
174
175
            throw new ServerException($exception->getMessage(), $exception->getCode(), $exception);
176
        }
177
178
        $this->delete($bucket, $oldname);
179
180
        return true;
181
    }
182
183
    /**
184
     * {@inheritdoc}
@@ 186-205 (lines=20) @@
183
    /**
184
     * {@inheritdoc}
185
     */
186
    public function copy(BucketInterface $bucket, BucketInterface $destination, $name)
187
    {
188
        try {
189
            $request = $this->buildRequest('PUT', $destination, $name, [], [
190
                'Acl'         => $destination->getOption('public') ? 'public-read' : 'private',
191
                'Copy-Source' => $this->buildUri($bucket, $name)->getPath()
192
            ]);
193
194
            $this->client->send($request);
195
        } catch (ClientException $exception) {
196
            if ($exception->getCode() != 404) {
197
                //Some authorization or other error
198
                throw $exception;
199
            }
200
201
            throw new ServerException($exception->getMessage(), $exception->getCode(), $exception);
202
        }
203
204
        return true;
205
    }
206
207
    /**
208
     * Create instance of UriInterface based on provided bucket options and storage object name.