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

EventResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 11 3
A getItems() 0 4 1
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