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

AutoField   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 23 6
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