Completed
Pull Request — master (#246)
by Tobias
10:39
created

ShowResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Mailgun\Resource\Api\Webhook;
4
5
use Mailgun\Resource\ApiResponse;
6
7
/**
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
class ShowResponse implements ApiResponse
11
{
12
    /**
13
     * @var array
14
     */
15
    private $webhook = [];
16
17
    /**
18
     * @param array $webhook
19
     */
20
    public function __construct(array $webhook)
21
    {
22
        $this->webhook = $webhook;
23
    }
24
25
    /**
26
     * @param array $data
27
     *
28
     * @return ShowResponse
29
     */
30
    public static function create(array $data)
31
    {
32
        $webhook = [];
33
        if (isset($data['webhook'])) {
34
            $webhook = $data['webhook'];
35
        }
36
37
        return new self($webhook);
38
    }
39
40
    /**
41
     * @return string|null
42
     */
43
    public function getWebhookUrl()
44
    {
45
        if (isset($this->webhook['url'])) {
46
            return $this->webhook['url'];
47
        }
48
    }
49
}
50