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

MappingStep::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 2
rs 9.8666
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