Passed
Push — master ( 94b7c6...9cdec7 )
by Christian
15:16 queued 12s
created

PromotionIndividualCodeCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 23
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getApiAlias() 0 3 1
A getExpectedClass() 0 3 1
A getCodeArray() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Promotion\Aggregate\PromotionIndividualCode;
4
5
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
6
7
/**
8
 * @method void                               add(PromotionIndividualCodeEntity $entity)
9
 * @method void                               set(string $key, PromotionIndividualCodeEntity $entity)
10
 * @method PromotionIndividualCodeEntity[]    getIterator()
11
 * @method PromotionIndividualCodeEntity[]    getElements()
12
 * @method PromotionIndividualCodeEntity|null get(string $key)
13
 * @method PromotionIndividualCodeEntity|null first()
14
 * @method PromotionIndividualCodeEntity|null last()
15
 */
16
class PromotionIndividualCodeCollection extends EntityCollection
17
{
18
    public function getApiAlias(): string
19
    {
20
        return 'promotion_individual_code_collection';
21
    }
22
23
    /**
24
     * @returns string[]
25
     */
26
    public function getCodeArray(): array
27
    {
28
        $codes = [];
29
        foreach ($this->getIterator() as $codeEntity) {
30
            $codes[] = $codeEntity->getCode();
31
        }
32
33
        return $codes;
34
    }
35
36
    protected function getExpectedClass(): string
37
    {
38
        return PromotionIndividualCodeEntity::class;
39
    }
40
}
41