Completed
Push — master ( a12db9...82664b )
by Julito
86:55 queued 55:35
created

ArrayToIdentifierTransformer::reverseTransform()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\SettingsBundle\Transformer;
5
6
use Sylius\Bundle\SettingsBundle\Transformer\ParameterTransformerInterface;
7
8
/**
9
 * Object to identifier transformer.
10
 *
11
 * @author Julio Montoya
12
 */
13
class ArrayToIdentifierTransformer implements ParameterTransformerInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function transform($value)
19
    {
20
        if (!is_array($value)) {
21
            return '';
22
        }
23
24
        $value = implode(',', $value);
25
26
        return $value;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function reverseTransform($value)
33
    {
34
        if (empty($value)) {
35
            return [];
36
        }
37
38
        $value = explode(',', $value);
39
40
        return $value;
41
    }
42
}
43