Completed
Push — master ( 4a903b...b725ab )
by Tobias
03:23 queued 53s
created

Attachment   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 16
loc 16
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A show() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * Copyright (C) 2013 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Api;
11
12
use Mailgun\Assert;
13
use Mailgun\Model\Attachment\Attachment as Model;
14
use Psr\Http\Message\ResponseInterface;
15
16
/**
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19 View Code Duplication
class Attachment extends HttpApi
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * @return Model|ResponseInterface
23
     */
24 2
    public function show(string $url)
25
    {
26 2
        Assert::stringNotEmpty($url);
27 2
        Assert::regex($url, '@https://.*mailgun\.(net|org)/v.+@');
28 1
        Assert::regex($url, '|/attachments/[0-9]+|');
29
30
        $response = $this->httpGet($url);
31
32
        return $this->hydrateResponse($response, Model::class);
33
    }
34
}
35