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

HalfEvenAdapter::determineCarry()   A

Complexity

Conditions 5
Paths 6

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 5

Importance

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