ObjectCollectionToArrayTransformer::transform()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace DoS\ResourceBundle\Form\DataTransformer;
4
5
use Doctrine\Common\Collections\Collection;
6
use Symfony\Component\Form\DataTransformerInterface;
7
8
/**
9
 * Transform object collection to array.
10
 *
11
 * @author Liverbool <[email protected]>
12
 */
13
class ObjectCollectionToArrayTransformer implements DataTransformerInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function transform($value)
19
    {
20
        if ($value instanceof Collection) {
21
            return $value->toArray();
22
        }
23
24
        return $value;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function reverseTransform($value)
31
    {
32
        return $value;
33
    }
34
}
35