Passed
Pull Request — master (#81)
by
unknown
13:46
created

VariantPdfModelProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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