Completed
Push — master ( 479df9...de13ff )
by Sean
03:26
created

EventResponse::create()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 2
nop 1
crap 12
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