Completed
Pull Request — master (#249)
by David
10:15
created

ShowResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 2
A __construct() 0 4 1
A getRoute() 0 4 1
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\Resource\Api\Routes\Response;
11
12
use Mailgun\Resource\Api\Routes\Dto\RouteDto;
13
use Mailgun\Resource\ApiResponse;
14
15
/**
16
 * @author David Garcia <[email protected]>
17
 */
18
final class ShowResponse implements ApiResponse
19
{
20
    /**
21
     * @var RouteDto|null
22
     */
23
    private $route;
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public static function create(array $data)
29
    {
30
        if (isset($data['route'])) {
31
            return new self(RouteDto::create($data['route']));
32
        }
33
34
        return new self();
35
    }
36
37
    /**
38
     * ShowResponse constructor.
39
     *
40
     * @param RouteDto|null $route
41
     */
42
    private function __construct(RouteDto $route = null)
43
    {
44
        $this->route = $route;
45
    }
46
47
    /**
48
     * @return RouteDto|null
49
     */
50
    public function getRoute()
51
    {
52
        return $this->route;
53
    }
54
}
55