-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathFileRequestCollection.php
More file actions
55 lines (47 loc) · 1.14 KB
/
FileRequestCollection.php
File metadata and controls
55 lines (47 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Kunnu\Dropbox\Models;
class FileRequestCollection extends ModelCollection
{
/**
* Collection Items Key
*
* @const string
*/
const COLLECTION_ITEMS_KEY = 'file_requests';
/**
* Get the Collection Items Key
*
* @return string
*/
public function getCollectionItemsKey()
{
return static::COLLECTION_ITEMS_KEY;
}
/**
* Create a new FileRequest Collection
*
* @param array $data Collection Data
*/
public function __construct(array $data)
{
$this->data = $data;
$items = isset($data[$this->getCollectionItemsKey()]) ? $data[$this->getCollectionItemsKey()] : [];
$this->processItems($items);
}
/**
* Process items and cast them
* to their respective Models
*
* @param array $items Unprocessed Items
*
* @return void
*/
protected function processItems(array $items)
{
$processedItems = [];
foreach ($items as $entry) {
$processedItems[] = ModelFactory::make($entry);
}
$this->items = new ModelCollection($processedItems);
}
}