Completed
Pull Request — master (#44)
by
unknown
08:30
created

AttributeOption::convertProperty()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 19
rs 9.5555
cc 5
nc 3
nop 4
1
<?php
2
3
namespace Flagbit\Bundle\TableAttributeBundle\ArrayConverter\StandardToFlat;
4
5
use Akeneo\Pim\Structure\Component\ArrayConverter\StandardToFlat\AttributeOption as BaseArrayConverter;
6
7
class AttributeOption extends BaseArrayConverter
8
{
9
    protected function convertProperty($property, $data, array $convertedItem, array $options)
10
    {
11
        switch ($property) {
12
            case 'constraints':
13
                $convertedItem['constraints'] = implode(',', array_keys($data));
14
                break;
15
16
            case 'type_config':
17
                foreach ($data as $key => $value) {
18
                    $convertedItem['type_config-'.$key] = is_array($value) ? json_encode($value) : (string) $value;
19
                }
20
                break;
21
22
            default:
23
                $convertedItem = parent::convertProperty($property, $data, $convertedItem, $options);
24
                break;
25
        }
26
27
        return $convertedItem;
28
    }
29
}
30