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

HalfDownAdapter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 6
cts 7
cp 0.8571
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A determineCarry() 0 9 6
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
}