Completed
Pull Request — dev (#23)
by Jordan
02:47
created

Distribution::random()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Samsara\Fermat\Provider\Distribution\Base;
4
5
use Samsara\Fermat\Types\NumberCollection;
6
use Samsara\Fermat\Values\ImmutableNumber;
7
8
abstract class Distribution
9
{
10
11
    abstract public function random(): ImmutableNumber;
12
13
    /**
14
     * @param int $sampleSize
15
     * @return NumberCollection
16
     */
17
    public function randomSample(int $sampleSize = 10): NumberCollection
18
    {
19
        $sample = new NumberCollection();
20
21
        for ($i = 1;$i < $sampleSize;$i++) {
22
            $sample->push($this->random());
23
        }
24
25
        return $sample;
26
    }
27
28
     abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableNumber;
29
30
}