Completed
Push — master ( 2b45da...60f6b8 )
by Arnaud
16s queued 12s
created

ArrayField::isSortable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace LAG\AdminBundle\Field;
4
5
use Doctrine\Common\Collections\Collection;
6
use Iterator;
7
use LAG\AdminBundle\Configuration\ActionConfiguration;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
class ArrayField extends AbstractField
11
{
12 2
    public function configureOptions(OptionsResolver $resolver, ActionConfiguration $actionConfiguration)
13
    {
14
        $resolver
15 2
            ->setDefaults([
16 2
                'glue' => ',',
17
            ])
18 2
            ->setAllowedTypes('glue', 'string')
19
        ;
20 2
    }
21
22 2
    public function isSortable(): bool
23
    {
24 2
        return false;
25
    }
26
27 2
    public function render($value = null): string
28
    {
29 2
        if (null === $value) {
30 2
            return '';
31
        }
32
33 2
        if ($value instanceof Collection) {
34
            $value = $value->toArray();
35
        }
36
37 2
        if ($value instanceof Iterator) {
38
            $value = iterator_to_array($value);
39
        }
40
41 2
        return implode($this->options['glue'], $value);
42
    }
43
}
44