HalfAlternatingAdapter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
eloc 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A determineCarry() 0 12 5
1
<?php
2
3
namespace Samsara\Fermat\Core\Provider\RoundingModeAdapters\Modes;
4
5
/**
6
 *
7
 */
8
class HalfAlternatingAdapter extends BaseAdapter
9
{
10
    private int $alt = 1;
11
12
    /**
13
     * @inheritDoc
14
     */
15 2
    public function determineCarry(int $digit, int $nextDigit): int
16
    {
17 2
        $early = static::nonHalfEarlyReturn($digit);
18 2
        $remainder = $this->remainderCheck();
19
20 2
        if ($early == 0 && !$remainder) {
21 2
            $val = $this->alt;
22 2
            $this->alt = (int)!$val;
23
24 2
            return $val;
25
        } else {
26
            return (($early == 1 || $remainder) ? 1 : 0);
27
        }
28
    }
29
}