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

MappingStep   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A describe() 0 3 1
A execute() 0 12 2
A configureOptionResolver() 0 6 1
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