Completed
Pull Request — master (#245)
by Tobias
07:56
created

EventResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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