Completed
Push — master ( 4b0611...da5ccd )
by Tobias
06:14 queued 03:25
created

CreateResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 47
loc 47
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

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