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

ShowResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
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
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