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

IndexResponse::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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