Completed
Pull Request — master (#249)
by David
10:15
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
/*
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