HalfDownAdapter::determineCarry()   A
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 6
rs 9.2222
c 0
b 0
f 0
eloc 6
nc 8
nop 2
1
<?php
2
3
namespace Samsara\Fermat\Core\Provider\RoundingModeAdapters\Modes;
4
5
/**
6
 *
7
 */
8
class HalfDownAdapter extends BaseAdapter
9
{
10
11
    /**
12
     * @inheritDoc
13
     */
14 40
    public function determineCarry(int $digit, int $nextDigit): int
15
    {
16 40
        $negative = $this->isNegative;
17 40
        $remainder = $this->remainderCheck();
18
19 40
        if ($negative) {
20 20
            return $digit > 4 ? 1 : 0;
21
        } else {
22 20
            return $digit > 5 || ($digit == 5 && $remainder) ? 1 : 0;
23
        }
24
    }
25
}