HalfRandomAdapter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0
eloc 7
wmc 5

1 Method

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