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

ShowResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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