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

HalfUpAdapter::determineCarry()   A

Complexity

Conditions 6
Paths 8

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 6.288

Importance

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