IntegerGenerator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 74
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A end() 0 6 1
A generateInteger() 0 4 1
A generateRandomInt() 0 4 1
A getEnd() 0 4 1
A getStart() 0 4 1
A start() 0 6 1
1
<?php
2
3
namespace PragmaRX\Random\Generators;
4
5
trait IntegerGenerator
6
{
7
    protected $start = 0;
8
9
    protected $end = PHP_INT_MAX;
10
11
    /**
12
     * Set numeric end.
13
     *
14
     * @param int $end
15
     * @return $this
16
     */
17 1
    public function end($end)
18
    {
19 1
        $this->end = $end;
20
21 1
        return $this;
22
    }
23
24
    /**
25
     * Generate a random integer.
26
     *
27
     * @return int
28
     */
29 1
    protected function generateInteger()
30
    {
31 1
        return $this->generateRandomInt($this->getStart(), $this->getEnd());
32
    }
33
34
    /**
35
     * Generate a random integer.
36
     *
37
     * @param int $start
38
     * @param int $end
39
     * @return int
40
     */
41 2
    protected function generateRandomInt($start, $end)
42
    {
43 2
        return random_int($start, $end);
44
    }
45
46
    /**
47
     * Get numeric end.
48
     *
49
     * @return int
50
     */
51 1
    public function getEnd()
52
    {
53 1
        return $this->end;
54
    }
55
56
    /**
57
     * Get numeric start.
58
     *
59
     * @return int
60
     */
61 1
    public function getStart()
62
    {
63 1
        return $this->start;
64
    }
65
66
    /**
67
     * Set numeric start.
68
     *
69
     * @param int $start
70
     * @return $this
71
     */
72 1
    public function start($start)
73
    {
74 1
        $this->start = $start;
75
76 1
        return $this;
77
    }
78
}
79