Completed
Push — master ( 9292a7...4c27f1 )
by Carlos C
07:21
created

NumberFormatDataField   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogosPopulate\Database;
6
7
class NumberFormatDataField extends TextDataField implements DataFieldInterface
8
{
9 15
    public function __construct(string $name, int $decimals)
10
    {
11
        parent::__construct($name, function ($input) use ($decimals) {
12 14
            if ('' === $input) {
13 14
                return '';
14
            }
15 6
            return number_format(floatval($input), $decimals, '.', '');
16 15
        });
17 15
    }
18
}
19