CountField   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 15
ccs 0
cts 4
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 6 1
A getDataTransformer() 0 4 2
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