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

ErrorResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
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