Completed
Pull Request — master (#97)
by
unknown
03:44
created

SearchResults::processItems()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 1
crap 4
1
<?php
2
namespace Kunnu\Dropbox\Models;
3
4
class SearchResults extends MetadataCollection
5
{
6
    /**
7
     * Collection Items Key
8
     *
9
     * @const string
10
     */
11
    const COLLECTION_ITEMS_KEY = 'matches';
12
13
    /**
14
     * Collection Cursor Key
15
     *
16
     * @const string
17
     */
18
    const COLLECTION_CURSOR_KEY = 'start';
19
20
    /**
21
     * Collection has-more-items Key
22
     *
23
     * @const string
24
     */
25
    const COLLECTION_HAS_MORE_ITEMS_KEY = 'more';
26
27
    /**
28
     * Process items and cast them
29
     * to their respective Models
30
     *
31
     * @param array $items Unprocessed Items
32
     *
33
     * @return void
34
     */
35 3
    protected function processItems(array $items)
36
    {
37 3
        $processedItems = [];
38
39 3
        foreach ($items as $entry) {
40 3
            if (isset($entry['metadata']) && is_array($entry['metadata'])) {
41 3
                $processedItems[] = new SearchResult($entry);
42
            }
43
        }
44
45 3
        $this->items = new ModelCollection($processedItems);
46 3
    }
47
}
48