Passed
Push — 0.4 ( 487c21 )
by jean
05:10
created

MappingStep::configureOptionResolver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Darkilliant\ProcessBundle\Step;
4
5
use Symfony\Component\OptionsResolver\OptionsResolver;
6
use Darkilliant\ProcessBundle\State\ProcessState;
7
8
class MappingStep extends AbstractConfigurableStep
9
{
10 1
    public function configureOptionResolver(OptionsResolver $resolver): OptionsResolver
11
    {
12 1
        $resolver->setRequired(['init_data', 'mapping']);
13 1
        $resolver->setDefault('init_data', null);
14
15 1
        return parent::configureOptionResolver($resolver);
16
    }
17
18 2
    public function execute(ProcessState $state)
19
    {
20 2
        $data = $state->getOptions()['init_data'];
21
22 2
        if (is_array($data)) {
23 1
            $data = array_merge($data, $state->getOptions()['mapping']);
24
        } else {
25 1
            $data = $state->getOptions()['mapping'];
26
        }
27
28 2
        $state->setData($data);
29 2
        $this->describe($state);
30 2
    }
31
32 2
    public function describe(ProcessState $state)
33
    {
34 2
        $state->info('map data');
35 2
    }
36
}
37