Passed
Pull Request — master (#116)
by Arnaud
03:09
created

AutoField::render()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 12
nc 6
nop 1
dl 0
loc 23
rs 9.2222
c 0
b 0
f 0
1
<?php
2
3
namespace LAG\AdminBundle\Field;
4
5
class AutoField extends AbstractField
6
{
7
    public function render($value = null): string
8
    {
9
        if (null === $value) {
10
            return '';
11
        }
12
13
        if (is_string($value)) {
14
            return $value;
15
        }
16
17
        if (is_array($value)) {
18
            return implode(',', $value);
19
        }
20
21
        if (is_object($value)) {
22
            if (method_exists($value, '__toString')) {
23
                return (string) $value;
24
            } else {
25
                return serialize($value);
26
            }
27
        }
28
29
        return '';
30
    }
31
}
32