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

NumberFormatDataField::__construct()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 1
nop 2
crap 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