Completed
Push — master ( 2683bd...cf87f7 )
by Jordan
21s queued 13s
created

HalfDownAdapter::determineCarry()   A

Complexity

Conditions 6
Paths 8

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 6.105

Importance

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