Completed
Push — master ( 9f1a25...922242 )
by De Cramer
10s
created

RuleTransformFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Oliverde8\Component\PhpEtl\Builder\Factories\Transformer;
4
5
use Oliverde8\Component\PhpEtl\Builder\Factories\AbstractFactory;
6
use Oliverde8\Component\RuleEngine\RuleApplier;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * Class RuleTransformFactory
11
 *
12
 * @author    de Cramer Oliver<[email protected]>
13
 * @copyright 2018 Oliverde8
14
 * @package Oliverde8\Component\PhpEtl\Builder\Factories\Transformer
15
 */
16
class RuleTransformFactory extends AbstractFactory
17
{
18
    /** @var RuleApplier */
19
    protected $ruleApplier;
20
21
    /**
22
     * RuleTransformFactory constructor.
23
     *
24
     * @param string $operation
25
     * @param string $class
26
     * @param RuleApplier $ruleApplier
27
     */
28
    public function __construct($operation, $class, RuleApplier $ruleApplier)
29
    {
30
        parent::__construct($operation, $class);
31
        $this->ruleApplier = $ruleApplier;
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public function build($operation, $options)
38
    {
39
        return $this->create($this->ruleApplier, $options['columns'], $options['add']);
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    protected function configureValidator()
46
    {
47
        return new Assert\Collection([
48
            'columns' => [
49
                new Assert\Type(["type" => "array"]),
50
                new Assert\NotBlank(),
51
            ],
52
            'add' => new Assert\Type(["type" => "boolean"])
53
        ]);
54
    }
55
}