Passed
Push — master ( 146b61...80e19c )
by Mathew
05:37
created
src/Commands/CheckInvitation.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,7 @@
 block discarded – undo
47 47
         try {
48 48
             LaravelInvites::check($code, $email);
49 49
             $this->info('This code is valid');
50
-        }
51
-        catch(LaravelInvitesException $e)
50
+        } catch(LaravelInvitesException $e)
52 51
         {
53 52
             $this->error($e->getMessage());
54 53
         }
Please login to merge, or discard this patch.
src/Commands/GenerateInvitations.php 1 patch
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,12 +49,15 @@
 block discarded – undo
49 49
         $hours = $this->option('hours');
50 50
         $days = $this->option('days');
51 51
 
52
-        $invite = LaravelInvites::for($email)->allow($allow);
52
+        $invite = LaravelInvites::for($email) {
53
+            ->allow($allow);
54
+        }
53 55
 
54
-        if($days)
55
-            $invite->setExpiry(now()->addDays($days));
56
-        else if($hours)
57
-            $invite->setExpiry(now()->addHours($hours));
56
+        if($days) {
57
+                    $invite->setExpiry(now()->addDays($days));
58
+        } else if($hours) {
59
+                    $invite->setExpiry(now()->addHours($hours));
60
+        }
58 61
 
59 62
         $invites = $invite->generate($count);
60 63
 
Please login to merge, or discard this patch.
src/Mail/InvitationMail.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@
 block discarded – undo
42 42
         if($this->invite->valid_upto)
43 43
         {
44 44
             $url = URL::temporarySignedRoute('laravelinvites.routes.follow', $this->invite->valid_upto, $data);
45
-        }
46
-        else
45
+        } else
47 46
         {
48 47
             $url = URL::signedRoute('laravelinvites.routes.follow', $data);
49 48
         }
Please login to merge, or discard this patch.
src/Models/Invite.php 1 patch
Braces   +11 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@  discard block
 block discarded – undo
37 37
     {
38 38
         $this->increment('used_count');
39 39
 
40
-        if($this->used_count >= $this->allowed_count && config('laravelinvites.delete_on_full', true))
41
-            $this->delete();
40
+        if($this->used_count >= $this->allowed_count && config('laravelinvites.delete_on_full', true)) {
41
+                    $this->delete();
42
+        }
42 43
     }
43 44
 
44 45
     public function scopeValid($query)
@@ -59,13 +60,14 @@  discard block
 block discarded – undo
59 60
      */
60 61
     private function setDefaultExpiry()
61 62
     {
62
-        if(config('laravelinvites.expiry.type')==='none')
63
-            return null;
63
+        if(config('laravelinvites.expiry.type')==='none') {
64
+                    return null;
65
+        }
64 66
         
65
-        if(config('laravelinvites.expiry.type') === 'hours')
66
-            return now()->addHours(config('laravelinvites.expiry.value'));
67
-            
68
-        elseif(config('laravelinvites.expiry.type') === "days")
69
-            return now()->addDays(config('laravelinvites.expiry.days'));
67
+        if(config('laravelinvites.expiry.type') === 'hours') {
68
+                    return now()->addHours(config('laravelinvites.expiry.value'));
69
+        } elseif(config('laravelinvites.expiry.type') === "days") {
70
+                    return now()->addDays(config('laravelinvites.expiry.days'));
71
+        }
70 72
     }
71 73
 }
72 74
\ No newline at end of file
Please login to merge, or discard this patch.
src/Exceptions/InvitationNotValidWithEmailException.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,10 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct($email, $valid_email)
10 10
     {
11
-        if($email)
12
-            parent::__construct("This invitation code is not valid with this $email");
13
-        else
14
-            parent::__construct("This invitation code is valid only for $valid_email");
11
+        if($email) {
12
+                    parent::__construct("This invitation code is not valid with this $email");
13
+        } else {
14
+                    parent::__construct("This invitation code is valid only for $valid_email");
15
+        }
15 16
     }
16 17
 }
Please login to merge, or discard this patch.
src/LaravelInvites.php 1 patch
Braces   +41 added lines, -36 removed lines patch added patch discarded remove patch
@@ -44,10 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function get()
46 46
     {
47
-        if(!blank(optional($this->data)['email']))
48
-            $result =  Invite::valid()->whereEmail($this->data['email'])->first();
49
-        else
50
-            $result = Invite::valid()->get();
47
+        if(!blank(optional($this->data)['email'])) {
48
+                    $result =  Invite::valid()->whereEmail($this->data['email'])->first();
49
+        } else {
50
+                    $result = Invite::valid()->get();
51
+        }
51 52
 
52 53
         $this->initializeData();
53 54
 
@@ -65,8 +66,9 @@  discard block
 block discarded – undo
65 66
         $validator = Validator::make(compact('email'),[
66 67
             'email'=>'required|email'
67 68
         ]);
68
-        if($validator->fails())
69
-            throw new InvalidEmailIdException;
69
+        if($validator->fails()) {
70
+                    throw new InvalidEmailIdException;
71
+        }
70 72
 
71 73
         $this->data['email'] = $email;
72 74
 
@@ -77,8 +79,9 @@  discard block
 block discarded – undo
77 79
     {
78 80
         $invite = Invite::create($this->data);
79 81
 
80
-        if($invite->email && config('laravelinvites.mail.enabled', true))
81
-            Mail::to($invite->email)->send(new InvitationMail($invite));
82
+        if($invite->email && config('laravelinvites.mail.enabled', true)) {
83
+                    Mail::to($invite->email)->send(new InvitationMail($invite));
84
+        }
82 85
 
83 86
         return $invite;
84 87
     }
@@ -97,8 +100,9 @@  discard block
 block discarded – undo
97 100
      */
98 101
     private function prepare()
99 102
     {
100
-        if($this->number_of_invites == 1)
101
-            return $this->prepareSingle();
103
+        if($this->number_of_invites == 1) {
104
+                    return $this->prepareSingle();
105
+        }
102 106
 
103 107
         $invites = [];
104 108
 
@@ -121,15 +125,17 @@  discard block
 block discarded – undo
121 125
     {
122 126
         if(optional($this->data)['email'] && !blank($this->data['email']))
123 127
         {
124
-            if($number_of_invites > 1)
125
-                throw new AnEmailCanHaveOnlyOneInvitation;
128
+            if($number_of_invites > 1) {
129
+                            throw new AnEmailCanHaveOnlyOneInvitation;
130
+            }
126 131
 
127 132
             $validator = Validator::make($this->data,[
128 133
                 'email'=>'unique:'.config('laravelinvites.table').',email'
129 134
             ]);
130 135
 
131
-            if($validator->fails())
132
-                throw new AnEmailCanHaveOnlyOneInvitation;
136
+            if($validator->fails()) {
137
+                            throw new AnEmailCanHaveOnlyOneInvitation;
138
+            }
133 139
         }
134 140
 
135 141
         $this->number_of_invites = $number_of_invites;
@@ -219,28 +225,23 @@  discard block
 block discarded – undo
219 225
 
220 226
             $this->check($code, $email);
221 227
             return true;
222
-        }
223
-        catch(InvalidInvitationCodeException $e)
228
+        } catch(InvalidInvitationCodeException $e)
224 229
         {
225 230
             $validator->errors()->add($emailFieldName, ':attribute is invalid');
226 231
             return false;
227
-        }
228
-        catch(InvitationNotYetActiveException $e)
232
+        } catch(InvitationNotYetActiveException $e)
229 233
         {
230 234
             $validator->errors()->add($emailFieldName, ':attribute is not valid yet');
231 235
             return false;
232
-        }
233
-        catch(InvitationExpiredException $e)
236
+        } catch(InvitationExpiredException $e)
234 237
         {
235 238
             $validator->errors()->add($emailFieldName, ':attribute expired');
236 239
             return false;
237
-        }
238
-        catch(InvitationNotValidWithEmailException $e)
240
+        } catch(InvitationNotValidWithEmailException $e)
239 241
         {
240 242
             $validator->errors()->add($emailFieldName, ':attribute is not valid with the provided '.$emailFieldName);
241 243
             return false;
242
-        }
243
-        catch(MaximumUseOfCodeException $e)
244
+        } catch(MaximumUseOfCodeException $e)
244 245
         {
245 246
             $validator->errors()->add($emailFieldName, ':attribute has been used for the maximum possible times');
246 247
             return false;
@@ -261,8 +262,7 @@  discard block
 block discarded – undo
261 262
             $this->check($code, $email);
262 263
 
263 264
             return true;
264
-        }
265
-        catch(LaravelInvitesException $e)
265
+        } catch(LaravelInvitesException $e)
266 266
         {
267 267
             return false;
268 268
         }
@@ -278,20 +278,25 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $invite = Invite::whereCode($code)->first();
280 280
 
281
-        if(!$invite)
282
-            throw new InvalidInvitationCodeException;
281
+        if(!$invite) {
282
+                    throw new InvalidInvitationCodeException;
283
+        }
283 284
         
284
-        if($invite->valid_from > now())
285
-            throw new InvitationNotYetActiveException($invite->valid_from);
285
+        if($invite->valid_from > now()) {
286
+                    throw new InvitationNotYetActiveException($invite->valid_from);
287
+        }
286 288
 
287
-        if($invite->valid_upto && $invite->valid_upto <= now())
288
-            throw new InvitationExpiredException($invite->valid_upto);
289
+        if($invite->valid_upto && $invite->valid_upto <= now()) {
290
+                    throw new InvitationExpiredException($invite->valid_upto);
291
+        }
289 292
 
290
-        if($invite->used_count > ($invite->allowed_count-1))
291
-            throw new MaximumUseOfCodeException($invite->allowed_count);
293
+        if($invite->used_count > ($invite->allowed_count-1)) {
294
+                    throw new MaximumUseOfCodeException($invite->allowed_count);
295
+        }
292 296
 
293
-        if($invite->email !== $email && !blank($invite->email))
294
-            throw new InvitationNotValidWithEmailException($email, $invite->email);
297
+        if($invite->email !== $email && !blank($invite->email)) {
298
+                    throw new InvitationNotValidWithEmailException($email, $invite->email);
299
+        }
295 300
 
296 301
         return true;
297 302
     }
Please login to merge, or discard this patch.