This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
48
{
49
4
for ($i = $this->key(); $i < $this->getMaxLimit(); ++$i) {
50
4
if ($this->isPrimeNumber($i)) {
51
4
$this->key = $i;
52
53
4
return $i;
54
}
55
}
56
57
4
return $this->getMaxLimit();
58
}
59
60
/**
61
* {@inheritdoc}
62
*/
63
4
public function next()
64
{
65
4
++$this->key;
66
4
}
67
68
/**
69
* {@inheritdoc}
70
*/
71
4
public function valid()
72
{
73
4
return $this->current() < $this->getMaxLimit();
74
}
75
76
/**
77
* {@inheritdoc}
78
*/
79
4
public function rewind()
80
{
81
4
$this->key = $this->getMinLimit();
82
4
}
83
84
/**
85
* Set the maximum limit.
86
*
87
* @param int $max
88
* The limit
89
*/
90
4
public function setMaxLimit($max)
91
{
92
4
$this->max = $max;
93
4
}
94
95
/**
96
* Get the maximum limit.
97
*
98
* @return int
99
* The limit
100
*/
101
4
public function getMaxLimit()
102
{
103
4
return (int) $this->max;
104
}
105
106
/**
107
* Set the minimum limit.
108
*
109
* @param int $min
110
* The limit
111
*/
112
4
public function setMinLimit($min)
113
{
114
4
$this->min = $min;
115
4
}
116
117
/**
118
* Get the minimum limit.
119
*
120
* @return int
121
* The limit
122
*/
123
4
public function getMinLimit()
124
{
125
4
return $this->min <= 2 ? 2 : (int) $this->min;
126
}
127
128
/**
129
* Test if a number is prime or not.
130
*
131
* @param int $number
132
* The number to test
133
*
134
* @return bool
135
* The true if the number is prime, false otherwise
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.