Passed
Push — master ( c2eae6...17ee88 )
by Sébastien
02:33
created

NumberConversion::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @see       https://github.com/soluble-io/soluble-mediatools for the canonical repository
7
 *
8
 * @copyright Copyright (c) 2018-2019 Sébastien Vanvelthem. (https://github.com/belgattitude)
9
 * @license   https://github.com/soluble-io/soluble-mediatools/blob/master/LICENSE.md MIT
10
 */
11
12
namespace Soluble\MediaTools\Common\Math;
13
14
final class NumberConversion
15
{
16 2
    public static function truncateFloat(float $number, int $decimals): float
17
    {
18 2
        $power = 10 ** $decimals;
19 2
        if ($number > 0) {
20 2
            return floor($number * $power) / $power;
21
        }
22
23 1
        return ceil($number * $power) / $power;
24
    }
25
}
26