Completed
Push — master ( b3f24e...84a5c5 )
by Tobias
03:15
created

IndexResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A create() 11 11 3
A getItems() 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\Suppression\Bounce;
11
12
use Mailgun\Model\ApiResponse;
13
use Mailgun\Model\PaginationResponse;
14
use Mailgun\Model\PagingProvider;
15
16
/**
17
 * @author Sean Johnson <[email protected]>
18
 */
19 View Code Duplication
final class IndexResponse implements ApiResponse, PagingProvider
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...
20
{
21
    use PaginationResponse;
22
23
    /**
24
     * @var Bounce[]
25
     */
26
    private $items;
27
28
    /**
29
     * @param Bounce[] $items
30
     * @param array    $paging
31
     */
32
    private function __construct(array $items, array $paging)
33
    {
34
        $this->items = $items;
35
        $this->paging = $paging;
36
    }
37
38
    /**
39
     * @param array $data
40
     *
41
     * @return IndexResponse
42
     */
43
    public static function create(array $data)
44
    {
45
        $bounces = [];
46
        if (isset($data['items'])) {
47
            foreach ($data['items'] as $item) {
48
                $bounces[] = Bounce::create($item);
49
            }
50
        }
51
52
        return new self($bounces, $data['paging']);
53
    }
54
55
    /**
56
     * @return Bounce[]
57
     */
58
    public function getItems()
59
    {
60
        return $this->items;
61
    }
62
}
63