Exponential   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A calculate() 0 3 1
A getBase() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Eclipxe\SoftDaemon\Sequencers;
6
7
use Eclipxe\SoftDaemon\Sequencer;
8
9
/**
10
 * Exponential sequencer calculate = count ^ exp
11
 */
12
class Exponential implements Sequencer
13
{
14
    public const MIN_BASE = 2;
15
16
    /** @var int */
17
    protected $base;
18
19 5
    public function __construct(int $base = self::MIN_BASE)
20
    {
21 5
        $this->base = max(self::MIN_BASE, $base);
22
    }
23
24 5
    public function getBase(): int
25
    {
26 5
        return $this->base;
27
    }
28
29 3
    public function calculate(int $count): int
30
    {
31 3
        return $this->base ** $count - 1;
32
    }
33
}
34