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

SearchResults   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 44
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A processItems() 0 12 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