Passed
Pull Request — master (#81)
by
unknown
14:34
created

VariantPdfModelProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A createVariantPdfModelCollection() 0 12 2
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusWishlistPlugin\Processor;
13
14
use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistItem;
15
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModel;
16
use BitBag\SyliusWishlistPlugin\Services\Generator\ModelCreatorInterface;
17
use Doctrine\Common\Collections\ArrayCollection;
18
use Doctrine\Common\Collections\Collection;
19
20
final class VariantPdfModelProcessor implements VariantPdfModelProcessorInterface
21
{
22
    private ModelCreatorInterface $pdfModelCreator;
23
24
    public function __construct(ModelCreatorInterface $pdfModelCreator)
25
    {
26
        $this->pdfModelCreator = $pdfModelCreator;
27
    }
28
29
    public function createVariantPdfModelCollection(Collection $wishlistProducts): ArrayCollection
30
    {
31
        $pdfModelsCollection = new ArrayCollection();
32
33
        /** @var WishlistItem $wishlistProduct */
34
        foreach ($wishlistProducts as $wishlistProduct) {
35
            /** @var VariantPdfModel $variantPdfModel */
36
            $variantPdfModel = $this->pdfModelCreator->createWishlistItemToPdf($wishlistProduct);
37
            $pdfModelsCollection->add($variantPdfModel);
38
        }
39
40
        return $pdfModelsCollection;
41
    }
42
}
43