Completed
Push — master ( da873d...74929b )
by Tobias
03:47
created

ErrorResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 50
loc 50
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A create() 7 7 3
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\Model;
11
12 View Code Duplication
final class ErrorResponse 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...
13
{
14
    /**
15
     * @var string
16
     */
17
    private $message;
18
19
    /**
20
     * @var string
21
     */
22
    private $error;
23
24
    /**
25
     * @param string $error
26
     */
27
    private function __construct($message, $error)
28
    {
29
        $this->message = $message;
30
        $this->error = $error;
31
    }
32
33
    /**
34
     * @param array
35
     *
36
     * @return self
37
     */
38
    public static function create(array $data)
39
    {
40
        return new self(
41
            isset($data['message']) ? $data['message'] : null,
42
            isset($data['error']) ? $data['error'] : null
43
        );
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getMessage()
50
    {
51
        return $this->message;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getError()
58
    {
59
        return $this->error;
60
    }
61
}
62