NumberFormatDataField::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
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 5
cts 5
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 28
    public function __construct(string $name, int $decimals)
10
    {
11 28
        parent::__construct($name, function ($input) use ($decimals) {
12 26
            if ('' === $input) {
13 26
                return '';
14
            }
15 10
            return number_format(floatval($input), $decimals, '.', '');
16 28
        });
17
    }
18
}
19