Code Duplication    Length = 20-22 lines in 2 locations

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

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