Code Duplication    Length = 24-25 lines in 2 locations

src/Gaufrette/Adapter/AwsS3.php 1 location

@@ 258-282 (lines=25) @@
255
     * @throws \RuntimeException if the bucket does not exists or could not be
256
     *                           created
257
     */
258
    protected function ensureBucketExists()
259
    {
260
        if ($this->bucketExists) {
261
            return true;
262
        }
263
264
        if ($this->bucketExists = $this->service->doesBucketExist($this->bucket)) {
265
            return true;
266
        }
267
268
        if (!$this->options['create']) {
269
            throw new \RuntimeException(sprintf(
270
                'The configured bucket "%s" does not exist.',
271
                $this->bucket
272
            ));
273
        }
274
275
        $this->service->createBucket([
276
            'Bucket' => $this->bucket,
277
            'LocationConstraint' => $this->service->getRegion(),
278
        ]);
279
        $this->bucketExists = true;
280
281
        return true;
282
    }
283
284
    protected function getOptions($key, array $options = [])
285
    {

src/Gaufrette/Adapter/AsyncAwsS3.php 1 location

@@ 271-294 (lines=24) @@
268
     * @throws \RuntimeException if the bucket does not exists or could not be
269
     *                           created
270
     */
271
    protected function ensureBucketExists()
272
    {
273
        if ($this->bucketExists) {
274
            return true;
275
        }
276
277
        if ($this->bucketExists = $this->service->bucketExists(['Bucket' => $this->bucket])->isSuccess()) {
278
            return true;
279
        }
280
281
        if (!$this->options['create']) {
282
            throw new \RuntimeException(sprintf(
283
                'The configured bucket "%s" does not exist.',
284
                $this->bucket
285
            ));
286
        }
287
288
        $this->service->createBucket([
289
            'Bucket' => $this->bucket,
290
        ]);
291
        $this->bucketExists = true;
292
293
        return true;
294
    }
295
296
    protected function getOptions($key, array $options = [])
297
    {