Completed
Push — master ( e24a08...649c71 )
by Joshua
9s
created

Collection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 1
cbo 3
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getIdentifiers() 0 13 5
A getQueryField() 0 4 1
1
<?php
2
3
namespace As3\Modlr\Models\Collections;
4
5
use As3\Modlr\Models\Model;
6
7
/**
8
 * Model collection that contains record representations from a persistence (database) layer.
9
 *
10
 * @author Jacob Bare <[email protected]>
11
 */
12
class Collection extends ModelCollection
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17
    public function getIdentifiers($onlyUnloaded = true)
18
    {
19
        $identifiers = [];
20
        foreach ($this->models as $model) {
21
            if (!$model instanceof Model) {
22
                continue;
23
            }
24
            if (true === $onlyUnloaded && true === $model->getState()->is('empty')) {
25
                $identifiers[] = $model->getId();
26
            }
27
        }
28
        return $identifiers;
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    public function getQueryField()
35
    {
36
        return 'id';
37
    }
38
}
39