Passed
Pull Request — master (#21)
by De Cramer
07:15
created

SplitItemFactory::__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 2
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Oliverde8\Component\PhpEtl\Builder\Factories\Transformer;
6
7
use Oliverde8\Component\PhpEtl\Builder\Factories\AbstractFactory;
8
use Oliverde8\Component\PhpEtl\ChainOperation\ChainOperationInterface;
9
use Symfony\Component\Validator\Constraint;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
/**
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2022 Oliverde8
15
 * @package Oliverde8\Component\PhpEtl\Builder\Factories\Transformer
16
 */
17
class SplitItemFactory extends AbstractFactory
18
{
19
20
21
    public function __construct(string $operation, string $class)
22
    {
23
        parent::__construct($operation, $class);
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function build(string $operation, array $options): ChainOperationInterface
30
    {
31
        return $this->create($options['singleElement'] ?? true, $options['keys']);
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    protected function configureValidator(): Constraint
38
    {
39
        return new Assert\Collection([
40
            'keys' => [
41
                new Assert\Type(["type" => "array"]),
42
                new Assert\NotBlank(),
43
            ],
44
            'singleElement' => new Assert\Type(["type" => "boolean"])
45
        ]);
46
    }
47
}