createNewWithValues()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 3
nc 4
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Created by solutionDrive GmbH
7
 *
8
 * @copyright 2018 solutionDrive GmbH
9
 */
10
11
namespace solutionDrive\SyliusProductBundlesPlugin\Factory;
12
13
use solutionDrive\SyliusProductBundlesPlugin\Service\Options\ProductBundleSlotOptions;
14
use solutionDrive\SyliusProductBundlesPlugin\Service\Options\ProductBundleSlotOptionsInterface;
15
16
class ProductBundleSlotOptionsFactory implements ProductBundleSlotOptionsFactoryInterface
17
{
18
    public function createNew(): ProductBundleSlotOptionsInterface
19
    {
20
        return new ProductBundleSlotOptions();
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function createNewWithValues(
27
        int $position,
28
        bool $isPresentationSlot = false,
29
        array $additionalOptions = []
30
    ): ProductBundleSlotOptionsInterface {
31
        $productBundleSlotOptions = $this->createNew();
32
        $productBundleSlotOptions->setPosition($position);
33
34
        if ($isPresentationSlot) {
35
            $productBundleSlotOptions->setAsPresentationSlot();
36
        }
37
38
        foreach ($additionalOptions as $name => $value) {
39
            $productBundleSlotOptions->addOption($name, $value);
40
        }
41
42
        return $productBundleSlotOptions;
43
    }
44
}
45