Completed
Pull Request — master (#245)
by Tobias
17:36 queued 07:28
created

EventResponse::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Resource\Api\Event;
11
12
use Mailgun\Resource\Api\PaginationResponse;
13
use Mailgun\Resource\ApiResponse;
14
15
/**
16
 * @author Tobias Nyholm <[email protected]>
17
 */
18
class EventResponse implements ApiResponse
19
{
20
    use PaginationResponse;
21
22
    /**
23
     * @var Event[]
24
     */
25
    private $items;
26
27
    /**
28
     * @param Event[] $items
29
     * @param array   $paging
30
     */
31
    public function __construct(array $items, array $paging)
32
    {
33
        $this->items = $items;
34
        $this->paging = $paging;
35
    }
36
37
    public static function create(array $data)
38
    {
39
        $events = [];
40
        if (isset($data['items'])) {
41
            foreach ($data['items'] as $item) {
42
                $events[] = Event::create($item);
43
            }
44
        }
45
46
        return new self($events, $data['paging']);
47
    }
48
49
    /**
50
     * @return Event[]
51
     */
52
    public function getItems()
53
    {
54
        return $this->items;
55
    }
56
}
57