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

HalfAlternatingAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
ccs 7
cts 9
cp 0.7778
rs 10
wmc 5

1 Method

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