ObjectCollectionToArrayTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A reverseTransform() 0 4 1
A transform() 0 8 2
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