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

HalfRandomAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

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

1 Method

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