RoundHalfAwayFromZero::round()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace byrokrat\amount\Rounder;
6
7
/**
8
 * Round to nearest and break ties by rounding half-way values away from zero
9
 */
10
class RoundHalfAwayFromZero implements \byrokrat\amount\Rounder
11
{
12
    use ToolkitConsumer;
13
14
    public function round(string $value, int $precision): string
15
    {
16 3
        return $this->toolkit->roundToNearest($value, $precision, function ($value, $precision) {
17 2
            return $this->toolkit->roundAwayFromZero($value, $precision);
18 3
        });
19
    }
20
}
21