RandomFloatVariable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
/**
3
 * NextFlow (http://github.com/nextflow)
4
 *
5
 * @link http://github.com/nextflow/nextflow-php for the canonical source repository
6
 * @copyright Copyright (c) 2014-2016 NextFlow (http://github.com/nextflow)
7
 * @license https://raw.github.com/nextflow/nextflow-php/master/LICENSE MIT
8
 */
9
10
namespace NextFlow\Math\Variable;
11
12
use NextFlow\Php\Variable\FloatVariable;
13
14
/**
15
 * A variable that holds a random float variable.
16
 */
17
final class RandomFloatVariable extends FloatVariable
18
{
19
    /**
20
     * Initializes a new instance of this class.
21
     *
22
     * @param float $min The minimum value.
23
     * @param float $max The maximum value.
24
     * @param float $decimals The amount of decimals to round to.
25
     */
26
    public function __construct($min = 0.0, $max = 1.0, $decimals = 0)
27
    {
28
        $value = ($min + lcg_value() * (abs($max - $min)));
29
        if ($decimals != 0) {
30
            $value = round($value, $decimals);
31
        }
32
33
        parent::__construct($value);
34
    }
35
}
36