ProductBundleSlotOptionsFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createNew() 0 4 1
A createNewWithValues() 0 18 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