Completed
Push — master ( 8e9b2d...71f485 )
by Quentin
17:01 queued 12:32
created

ComponentCollection::buildRanking()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Synapse\Cmf\Framework\Theme\Component\Entity;
4
5
use Majora\Framework\Model\EntityCollection;
6
use Synapse\Cmf\Framework\Theme\Component\Model\ComponentInterface;
7
8
/**
9
 * Component entity collection class.
10
 */
11
class ComponentCollection extends EntityCollection
12
{
13
    /**
14
     * @see EntityCollection::getEntityClass()
15
     */
16 2
    public function getEntityClass()
17
    {
18 2
        return Component::class;
19
    }
20
21
    /**
22
     * Build ranking index for this collection of components.
23
     *
24
     * @return self
25
     */
26 6
    public function buildRanking()
27
    {
28 6
        $i = 0;
29
30 6
        return $this->map(function (ComponentInterface $component) use (&$i) {
31 6
            return $component->setRanking(++$i);
32 6
        });
33
    }
34
}
35