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

DeleteResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 51
loc 51
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 7 7 3
A __construct() 5 5 1
A getMessage() 4 4 1
A getError() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\ApiResponse;
13
14
/**
15
 * @author David Garcia <[email protected]>
16
 */
17 View Code Duplication
final class DeleteResponse implements ApiResponse
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
18
{
19
    /**
20
     * @var string
21
     */
22
    private $message;
23
24
    /**
25
     * @var string
26
     */
27
    private $error;
28
29
    /**
30
     * @param array $data
31
     *
32
     * @return self
33
     */
34
    public static function create(array $data)
35
    {
36
        return new self(
37
            isset($data['message']) ? $data['message'] : null,
38
            isset($data['error']) ? $data['error'] : null
39
        );
40
    }
41
42
    /**
43
     * @param string $message
44
     * @param string $error
45
     */
46
    private function __construct($message, $error)
47
    {
48
        $this->message = $message;
49
        $this->error = $error;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getMessage()
56
    {
57
        return $this->message;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getError()
64
    {
65
        return $this->error;
66
    }
67
}
68