CountField::getDataTransformer()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Field;
6
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
9
class CountField extends AbstractField
10
{
11
    public function configureOptions(OptionsResolver $resolver): void
12
    {
13
        $resolver->setDefaults([
14
            'template' => '@LAGAdmin/fields/string.html.twig',
15
            'translation' => false,
16
            'empty_string' => null,
17
        ]);
18
    }
19
20
    public function getDataTransformer(): ?\Closure
21
    {
22
        return function ($data) {
23
            return is_countable($data) ? \count($data) : 0;
24
        };
25
    }
26
}
27