Completed
Push — master ( 7705cb...ad67b4 )
by Tobias
03:39
created

Attachment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 20
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A show() 0 14 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Api;
13
14
use Mailgun\Assert;
15
use Psr\Http\Message\ResponseInterface;
16
17
/**
18
 * @author Tobias Nyholm <[email protected]>
19
 */
20
class Attachment extends HttpApi
21
{
22
    /**
23
     * @return ResponseInterface
24
     */
25 3
    public function show(string $url)
26
    {
27 3
        Assert::stringNotEmpty($url);
28 3
        Assert::regex($url, '@https://.*mailgun\.(net|org)/v.+@');
29 2
        Assert::regex($url, '|/attachments/[0-9]+|');
30
31 1
        $response = $this->httpGet($url);
32
33 1
        if (200 !== $response->getStatusCode()) {
34
            $this->handleErrors($response);
35
        }
36
37 1
        return $response;
38
    }
39
}
40