Completed
Push — nyx-delete-component ( b55c61 )
by Quentin
14:12
created

ComponentCollection::buildRanking()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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
    public function getEntityClass()
17
    {
18
        return Component::class;
19
    }
20
21
    /**
22
     * Build ranking index for this collection of components.
23
     *
24
     * @return self
25
     */
26
    public function buildRanking()
27
    {
28
        $i = 0;
29
30
        return $this->map(function (ComponentInterface $component) use (&$i) {
31
            return $component->setRanking(++$i);
32
        });
33
    }
34
}
35