@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Josh\Faker; |
4 | 4 | |
5 | -if(! function_exists('string')){ |
|
5 | +if (!function_exists('string')) { |
|
6 | 6 | /** |
7 | 7 | * Return string of variable |
8 | 8 | * |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if(! function_exists('faker')){ |
|
20 | +if (!function_exists('faker')) { |
|
21 | 21 | /** |
22 | 22 | * Return the faker instance |
23 | 23 | * |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -if(! function_exists('randomNumber')){ |
|
34 | +if (!function_exists('randomNumber')) { |
|
35 | 35 | /** |
36 | 36 | * Return random number |
37 | 37 | * |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | |
48 | 48 | $number = ''; |
49 | 49 | |
50 | - for($i = 1;$i <= $length;$i++){ |
|
51 | - $num = $numbers[rand(0,strlen($numbers) - 1)]; |
|
52 | - if($num == 0 && $i == 1){ |
|
50 | + for ($i = 1; $i <= $length; $i++) { |
|
51 | + $num = $numbers[rand(0, strlen($numbers) - 1)]; |
|
52 | + if ($num == 0 && $i == 1) { |
|
53 | 53 | continue; |
54 | 54 | } |
55 | 55 | |
56 | - $number .= $num ; |
|
56 | + $number .= $num; |
|
57 | 57 | } |
58 | 58 | |
59 | - if($int){ |
|
59 | + if ($int) { |
|
60 | 60 | return (integer)$number; |
61 | 61 | } |
62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | -if(! function_exists('randomString')){ |
|
67 | +if (!function_exists('randomString')) { |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Get random string |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | * @param null $type |
76 | 76 | * @return string |
77 | 77 | */ |
78 | - function randomString($length = 20, $type = null){ |
|
78 | + function randomString($length = 20, $type = null) { |
|
79 | 79 | |
80 | 80 | $characters = [ |
81 | 81 | 'uppercase' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', |
82 | 82 | 'lowercase' => 'abcdefghijklmnopqrstuvwxyz' |
83 | 83 | ]; |
84 | 84 | |
85 | - if(($type !== 'uppercase' && $type !== 'lowercase') && ! is_null($type)){ |
|
85 | + if (($type !== 'uppercase' && $type !== 'lowercase') && !is_null($type)) { |
|
86 | 86 | throw new \Exception("The type of $type does not exists!"); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $characters = array_merge($characters); |
90 | 90 | |
91 | - if(! is_null($type)){ |
|
91 | + if (!is_null($type)) { |
|
92 | 92 | $characters = $characters[$type]; |
93 | 93 | } |
94 | 94 | |
95 | - $string = ''; |
|
95 | + $string = ''; |
|
96 | 96 | |
97 | - for($i = 1;$i <= $length;$i++){ |
|
98 | - $string .= $characters[rand(0,strlen($characters) - 1)]; |
|
97 | + for ($i = 1; $i <= $length; $i++) { |
|
98 | + $string .= $characters[rand(0, strlen($characters) - 1)]; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $string; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | -if(! function_exists('isMeliCode')){ |
|
106 | +if (!function_exists('isMeliCode')) { |
|
107 | 107 | /** |
108 | 108 | * Check is meli code function |
109 | 109 | * |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | $value = '0' . $value; |
123 | 123 | } |
124 | 124 | for ($i = 0; $i <= 8; $i++) { |
125 | - $sub = $sub + ( $value[$i] * ( 10 - $i ) ); |
|
125 | + $sub = $sub + ($value[$i] * (10 - $i)); |
|
126 | 126 | } |
127 | - if (( $sub % 11 ) < 2) { |
|
128 | - $control = ( $sub % 11 ); |
|
127 | + if (($sub % 11) < 2) { |
|
128 | + $control = ($sub % 11); |
|
129 | 129 | } else { |
130 | - $control = 11 - ( $sub % 11 ); |
|
130 | + $control = 11 - ($sub % 11); |
|
131 | 131 | } |
132 | 132 | if ($value[9] == $control) { |
133 | 133 | return true; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $service = $this->getRandomKey('mailServices'); |
113 | 113 | |
114 | - return string(randomString(30,'lowercase') . '@' . $service); |
|
114 | + return string(randomString(30, 'lowercase') . '@' . $service); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | $domain = $this->getRandomKey('domains'); |
127 | 127 | |
128 | - return string(randomString(20,'lowercase') . $domain); |
|
128 | + return string(randomString(20, 'lowercase') . $domain); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function pageUrl() |
153 | 153 | { |
154 | - $rand = rand(3,7); |
|
154 | + $rand = rand(3, 7); |
|
155 | 155 | |
156 | 156 | $string = ''; |
157 | 157 | |
158 | - $count = rand(2,8); |
|
158 | + $count = rand(2, 8); |
|
159 | 159 | |
160 | - for($i=0;$i < $rand;$i++){ |
|
161 | - $string .= randomString($count,'lowercase') . '/'; |
|
160 | + for ($i = 0; $i < $rand; $i++) { |
|
161 | + $string .= randomString($count, 'lowercase') . '/'; |
|
162 | 162 | } |
163 | 163 | |
164 | - return rtrim($string,'/'); |
|
164 | + return rtrim($string, '/'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function age($min = 16, $max = 70) |
177 | 177 | { |
178 | - return rand($min,$max); |
|
178 | + return rand($min, $max); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -212,33 +212,33 @@ discard block |
||
212 | 212 | public function meliCode() |
213 | 213 | { |
214 | 214 | $i = 0; |
215 | - $code= null; |
|
215 | + $code = null; |
|
216 | 216 | |
217 | - while($i <= 100){ |
|
217 | + while ($i <= 100) { |
|
218 | 218 | |
219 | - $meli = randomNumber(10,true); |
|
219 | + $meli = randomNumber(10, true); |
|
220 | 220 | |
221 | - if(strlen($meli) != 10){ |
|
221 | + if (strlen($meli) != 10) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | - $c = substr($meli,9,1); |
|
225 | + $c = substr($meli, 9, 1); |
|
226 | 226 | |
227 | - $n = substr($meli,0,1) * 10 + |
|
228 | - substr($meli,1,1) * 9 + |
|
229 | - substr($meli,2,1) * 8 + |
|
230 | - substr($meli,3,1) * 7 + |
|
231 | - substr($meli,4,1) * 6 + |
|
232 | - substr($meli,5,1) * 5 + |
|
233 | - substr($meli,6,1) * 4 + |
|
234 | - substr($meli,7,1) * 3 + |
|
235 | - substr($meli,8,1) * 2; |
|
227 | + $n = substr($meli, 0, 1) * 10 + |
|
228 | + substr($meli, 1, 1) * 9 + |
|
229 | + substr($meli, 2, 1) * 8 + |
|
230 | + substr($meli, 3, 1) * 7 + |
|
231 | + substr($meli, 4, 1) * 6 + |
|
232 | + substr($meli, 5, 1) * 5 + |
|
233 | + substr($meli, 6, 1) * 4 + |
|
234 | + substr($meli, 7, 1) * 3 + |
|
235 | + substr($meli, 8, 1) * 2; |
|
236 | 236 | |
237 | 237 | $r = $n - (int)($n / 11) * 11; |
238 | 238 | |
239 | 239 | if (($r == 0 && $r == $c) || ($r == 1 && $c == 1) || ($r > 1 && $c == 11 - $r)) { |
240 | 240 | |
241 | - if(! isMeliCode($meli)){ |
|
241 | + if (!isMeliCode($meli)) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | $name = null; |
267 | 267 | $array = []; |
268 | 268 | |
269 | - if(is_array($object)){ |
|
269 | + if (is_array($object)) { |
|
270 | 270 | $array = $object; |
271 | 271 | $name = array_rand($object); |
272 | - } elseif(is_string($object)) { |
|
272 | + } elseif (is_string($object)) { |
|
273 | 273 | $array = $this->objects[$object]; |
274 | 274 | $name = array_rand($array); |
275 | 275 | } |