Completed
Push — master ( 196be9...9aed5e )
by David
01:32
created

ShowResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 31
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 8 1
A getWebhookUrl() 0 8 2
A getWebhookUrls() 0 4 1
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\Model\Webhook;
13
14
use Mailgun\Model\ApiResponse;
15
16
/**
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
final class ShowResponse implements ApiResponse
20
{
21
    private $webhook = [];
22
23 1
    private function __construct()
24
    {
25 1
    }
26
27 1
    public static function create(array $data): self
28
    {
29 1
        $model = new self();
30
31 1
        $model->webhook = $data['webhook'] ?? [];
32
33 1
        return $model;
34
    }
35
36
    public function getWebhookUrl(): ?string
37
    {
38
        foreach ($this->getWebhookUrls() as $url) {
39
            return $url;
40
        }
41
42
        return null;
43
    }
44
45 1
    public function getWebhookUrls(): array
46
    {
47 1
        return $this->webhook['urls'] ?? [];
48
    }
49
}
50