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

PagesResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

3 Methods

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