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

IndexResponse::create()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 8
cts 8
cp 1
rs 9.8666
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
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\Member;
11
12
use Mailgun\Model\PagingProvider;
13
use Mailgun\Model\PaginationResponse;
14
use Mailgun\Model\ApiResponse;
15
16 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...
17
{
18
    use PaginationResponse;
19
20
    /**
21
     * @var Member[]
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[] = Member::create($item);
37 1
            }
38 1
        }
39
40 1
        return new self($items, $data['paging']);
41
    }
42
43
    /**
44
     * @param Member[] $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 Member[]
55
     */
56 1
    public function getItems()
57
    {
58 1
        return $this->items;
59
    }
60
}
61