TextConverter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A convert() 0 14 2
1
<?php
2
3
namespace Pim\Bundle\ExcelConnectorBundle\ArrayConverter\Flat\Product\ValueConverter;
4
5
use Pim\Component\Connector\ArrayConverter\Flat\Product\FieldSplitter;
6
use Pim\Component\Connector\ArrayConverter\Flat\Product\ValueConverter\AbstractValueConverter;
7
8
/**
9
 * Converts text value into structured one.
10
 *
11
 * @author    Yohan Blain <[email protected]>
12
 * @copyright 2016 Akeneo SAS (http://www.akeneo.com)
13
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
 */
15
class TextConverter extends AbstractValueConverter
16
{
17
    /**
18
     * @param FieldSplitter $fieldSplitter
19
     * @param array         $supportedFieldType
20
     */
21
    public function __construct(FieldSplitter $fieldSplitter, array $supportedFieldType)
22
    {
23
        parent::__construct($fieldSplitter);
24
25
        $this->supportedFieldType = $supportedFieldType;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function convert(array $attributeFieldInfo, $value)
32
    {
33
        if ('' !== $value) {
34
            $data = (string) $value;
35
        } else {
36
            $data = null;
37
        }
38
39
        return [$attributeFieldInfo['attribute']->getCode() => [[
40
            'locale' => $attributeFieldInfo['locale_code'],
41
            'scope'  => $attributeFieldInfo['scope_code'],
42
            'data'   => $data,
43
        ]]];
44
    }
45
}
46