Completed
Push — master ( 2994aa...19d116 )
by Patrick
08:28
created

FileRequestCollection::getCollectionItemsKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
namespace Dropbox\Models;
3
4
class FileRequestCollection extends ModelCollection
5
{
6
7
    /**
8
     * Collection Items Key
9
     *
10
     * @const string
11
     */
12
    const COLLECTION_ITEMS_KEY = 'file_requests';
13
14
    /**
15
     * Get the Collection Items Key
16
     *
17
     * @return string
18
     */
19
    public function getCollectionItemsKey()
20
    {
21
        return static::COLLECTION_ITEMS_KEY;
22
    }
23
24
    /**
25
     * Create a new FileRequest Collection
26
     *
27
     * @param array $data Collection Data
28
     */
29
    public function __construct(array $data)
30
    {
31
        $this->data = $data;
32
33
        $items = isset($data[$this->getCollectionItemsKey()]) ? $data[$this->getCollectionItemsKey()] : [];
34
        $this->processItems($items);
35
    }
36
37
    /**
38
     * Process items and cast them
39
     * to their respective Models
40
     *
41
     * @param array $items Unprocessed Items
42
     *
43
     * @return void
44
     */
45 View Code Duplication
    protected function processItems(array $items)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        $processedItems = [];
48
49
        foreach ($items as $entry) {
50
            $processedItems[] = ModelFactory::make($entry);
51
        }
52
53
        $this->items = new ModelCollection($processedItems);
54
    }
55
}
56