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

ShowResponse::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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