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

Attachment::show()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 8
cp 0.875
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.0078
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