These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * Copyright (C) 2013 Mailgun |
||
7 | * |
||
8 | * This software may be modified and distributed under the terms |
||
9 | * of the MIT license. See the LICENSE file for details. |
||
10 | */ |
||
11 | |||
12 | namespace Mailgun\Model\Route; |
||
13 | |||
14 | use Mailgun\Model\ApiResponse; |
||
15 | |||
16 | /** |
||
17 | * @author David Garcia <[email protected]> |
||
18 | */ |
||
19 | View Code Duplication | final class CreateResponse implements ApiResponse |
|
0 ignored issues
–
show
|
|||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $message; |
||
25 | |||
26 | /** |
||
27 | * @var Route |
||
28 | */ |
||
29 | private $route; |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | 1 | public static function create(array $data) |
|
35 | { |
||
36 | 1 | $message = isset($data['message']) ? $data['message'] : null; |
|
37 | 1 | $route = isset($data['route']) ? Route::create($data['route']) : null; |
|
38 | |||
39 | 1 | return new self($message, $route); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * CreateResponse Private Constructor. |
||
44 | * |
||
45 | * @param string|null $message |
||
46 | */ |
||
47 | 1 | private function __construct($message = null, Route $route = null) |
|
48 | { |
||
49 | 1 | $this->message = $message; |
|
50 | 1 | $this->route = $route; |
|
51 | 1 | } |
|
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | 1 | public function getMessage() |
|
57 | { |
||
58 | 1 | return $this->message; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return Route |
||
63 | */ |
||
64 | 1 | public function getRoute() |
|
65 | { |
||
66 | 1 | return $this->route; |
|
67 | } |
||
68 | } |
||
69 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.