Completed
Push — master ( da873d...74929b )
by Tobias
03:47
created

ShowResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 9 2
A getWebhookUrl() 0 6 2
1
<?php
2
3
/*
4
 * Copyright (C) 2013-2016 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\Model\Webhook;
11
12
use Mailgun\Model\ApiResponse;
13
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
17
class ShowResponse implements ApiResponse
18
{
19
    /**
20
     * @var array
21
     */
22
    private $webhook = [];
23
24
    /**
25
     * @param array $webhook
26
     */
27
    public function __construct(array $webhook)
28
    {
29
        $this->webhook = $webhook;
30
    }
31
32
    /**
33
     * @param array $data
34
     *
35
     * @return ShowResponse
36
     */
37
    public static function create(array $data)
38
    {
39
        $webhook = [];
40
        if (isset($data['webhook'])) {
41
            $webhook = $data['webhook'];
42
        }
43
44
        return new self($webhook);
45
    }
46
47
    /**
48
     * @return string|null
49
     */
50
    public function getWebhookUrl()
51
    {
52
        if (isset($this->webhook['url'])) {
53
            return $this->webhook['url'];
54
        }
55
    }
56
}
57