HalfUpAdapter::determineCarry()   A
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 6

Importance

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