Conditions | 5 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 6.6 |
Changes | 0 |
1 | <?php |
||
25 | 6 | public function transform($value) |
|
26 | { |
||
27 | // already transformed (or null) |
||
28 | 6 | if (is_array($value) || is_null($value)) { |
|
29 | return $value; |
||
30 | } |
||
31 | |||
32 | 6 | if (!is_object($value)) { |
|
33 | throw new TransformationFailedException( |
||
34 | sprintf('Expected an object to transform, got "%s"', json_encode($value)) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | // load object if it's a Proxy |
||
39 | 6 | if ($value instanceof Proxy) { |
|
40 | $value->__load(); |
||
41 | } |
||
42 | |||
43 | 6 | $meta = $this->entityManager->getClassMetadata(get_class($value)); |
|
44 | |||
45 | 6 | return $meta->getIdentifierValues($value); |
|
46 | } |
||
47 | } |
||
48 |