Exponential::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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