Integer::stringify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Samshal\Rando\Packages\Basics;
4
5
use Samshal\Rando\Packages\PackageableInterface;
6
use Samshal\Rando\Packages\Packages;
7
8
class Integer extends Packages implements PackageableInterface
9
{
10
11
    protected $min;
12
    protected $max;
13
14
    public function setDefaults($defaultsArray = [])
15
    {
16
        $defaultsArray['min'] = -1 * mt_getrandmax();
17
        $defaultsArray['max'] = mt_getrandmax();
18
19
        return $defaultsArray;
20
    }
21
22
    protected function setMin($min)
23
    {
24
        $this->min = $min;
25
    }
26
27
    protected function setMax($max)
28
    {
29
        $this->max = $max;
30
    }
31
32
    private function generateDefaults()
33
    {
34
        if (empty($this->min)) {
35
            self::setMin($this->setDefaults()['min']);
36
        }
37
38
        if (empty($this->max)) {
39
            self::setMax($this->max = $this->setDefaults()['max']);
40
        }
41
    }
42
    private function generateInteger()
43
    {
44
        self::generateDefaults();
45
46
        return mt_rand($this->min, $this->max);
47
    }
48
49
    public function stringify()
50
    {
51
        return self::generateInteger();
52
    }
53
}
54