Completed
Push — develop ( 51dac5...f8095c )
by Alireza
01:53
created
src/helpers.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,18 +47,18 @@  discard block
 block discarded – undo
47 47
 
48 48
         $number  = '';
49 49
 
50
-        for($i = 1;$i <= $length;$i++){
51
-            $num = $numbers[rand(0,strlen($numbers) - 1)];
50
+        for ($i = 1; $i <= $length; $i++) {
51
+            $num = $numbers[rand(0, strlen($numbers) - 1)];
52 52
             
53
-            if($num == 0 && $i == 1){
53
+            if ($num == 0 && $i == 1) {
54 54
                 $i = 1;
55 55
                 continue;
56 56
             }
57 57
 
58
-            $number .= $num ;
58
+            $number .= $num;
59 59
         }
60 60
 
61
-        if($int){
61
+        if ($int) {
62 62
             return (integer)$number;
63 63
         }
64 64
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     }
67 67
 }
68 68
 
69
-if(! function_exists('randomString')){
69
+if (!function_exists('randomString')) {
70 70
 
71 71
     /**
72 72
      * Get random string
@@ -78,27 +78,27 @@  discard block
 block discarded – undo
78 78
      * @return string
79 79
      * @throws \Exception
80 80
      */
81
-    function randomString($length = 20, $type = null){
81
+    function randomString($length = 20, $type = null) {
82 82
 
83 83
         $characters = [
84 84
             'uppercase' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
85 85
             'lowercase' => 'abcdefghijklmnopqrstuvwxyz'
86 86
         ];
87 87
 
88
-        if(($type !== 'uppercase' && $type !== 'lowercase') && ! is_null($type)){
88
+        if (($type !== 'uppercase' && $type !== 'lowercase') && !is_null($type)) {
89 89
             throw new \Exception("The type of $type does not exists!");
90 90
         }
91 91
 
92
-        if(! is_null($type)){
92
+        if (!is_null($type)) {
93 93
             $characters = $characters[$type];
94 94
         } else {
95 95
             $characters = $characters['lowercase'] . $characters['uppercase'];
96 96
         }
97 97
 
98
-        $string  = '';
98
+        $string = '';
99 99
 
100
-        for($i = 1;$i <= $length;$i++){
101
-            $string .= $characters[rand(0,strlen($characters) - 1)];
100
+        for ($i = 1; $i <= $length; $i++) {
101
+            $string .= $characters[rand(0, strlen($characters) - 1)];
102 102
         }
103 103
 
104 104
         return $string;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 }
108 108
 
109
-if(! function_exists('isMeliCode')){
109
+if (!function_exists('isMeliCode')) {
110 110
     /**
111 111
      * Check is meli code function
112 112
      *
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
             $value = '0' . $value;
126 126
         }
127 127
         for ($i = 0; $i <= 8; $i++) {
128
-            $sub = $sub + ( $value[$i] * ( 10 - $i ) );
128
+            $sub = $sub + ($value[$i] * (10 - $i));
129 129
         }
130
-        if (( $sub % 11 ) < 2) {
131
-            $control = ( $sub % 11 );
130
+        if (($sub % 11) < 2) {
131
+            $control = ($sub % 11);
132 132
         } else {
133
-            $control = 11 - ( $sub % 11 );
133
+            $control = 11 - ($sub % 11);
134 134
         }
135 135
         if ($value[9] == $control) {
136 136
             return true;
Please login to merge, or discard this patch.
src/Generator.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
@@ -213,33 +213,33 @@  discard block
 block discarded – undo
213 213
     {
214 214
         $i = 1;
215 215
         
216
-        $code= null;
216
+        $code = null;
217 217
 
218
-        while($i <= 100){
218
+        while ($i <= 100) {
219 219
 
220
-            $meli = randomNumber(10,true);
220
+            $meli = randomNumber(10, true);
221 221
 
222
-            if(strlen($meli) != 10){
222
+            if (strlen($meli) != 10) {
223 223
                 continue;
224 224
             }
225 225
 
226
-            $c = substr($meli,9,1);
226
+            $c = substr($meli, 9, 1);
227 227
 
228
-            $n = substr($meli,0,1) * 10 +
229
-                substr($meli,1,1) * 9 +
230
-                substr($meli,2,1) * 8 +
231
-                substr($meli,3,1) * 7 +
232
-                substr($meli,4,1) * 6 +
233
-                substr($meli,5,1) * 5 +
234
-                substr($meli,6,1) * 4 +
235
-                substr($meli,7,1) * 3 +
236
-                substr($meli,8,1) * 2;
228
+            $n = substr($meli, 0, 1) * 10 +
229
+                substr($meli, 1, 1) * 9 +
230
+                substr($meli, 2, 1) * 8 +
231
+                substr($meli, 3, 1) * 7 +
232
+                substr($meli, 4, 1) * 6 +
233
+                substr($meli, 5, 1) * 5 +
234
+                substr($meli, 6, 1) * 4 +
235
+                substr($meli, 7, 1) * 3 +
236
+                substr($meli, 8, 1) * 2;
237 237
 
238 238
             $r = $n - (int)($n / 11) * 11;
239 239
 
240 240
             if (($r == 0 && $r == $c) || ($r == 1 && $c == 1) || ($r > 1 && $c == 11 - $r)) {
241 241
 
242
-                if(! isMeliCode($meli)){
242
+                if (!isMeliCode($meli)) {
243 243
                     continue;
244 244
                 }
245 245
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                 continue;
251 251
             }
252 252
             
253
-            if(is_null($code)){
253
+            if (is_null($code)) {
254 254
                 continue;
255 255
             }
256 256
             
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
         $name = null;
273 273
         $array = [];
274 274
 
275
-        if(is_array($object)){
275
+        if (is_array($object)) {
276 276
             $array = $object;
277 277
             $name = array_rand($object);
278
-        } elseif(is_string($object)) {
278
+        } elseif (is_string($object)) {
279 279
             $array = $this->objects[$object];
280 280
             $name = array_rand($array);
281 281
         }
Please login to merge, or discard this patch.