Passed
Push — develop ( 496513...c40afd )
by Mathew
06:30 queued 03:36
created
src/Commands/CheckInvitation.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@
 block discarded – undo
41 41
      */
42 42
     public function handle()
43 43
     {
44
-        $email = $this->argument('email') ? : null;
44
+        $email = $this->argument('email') ?: null;
45 45
         $code = $this->argument('code');
46 46
 
47 47
         try {
48 48
             LaravelInvites::check($code, $email);
49 49
             $this->info('This code is valid');
50 50
         }
51
-        catch(LaravelInvitesException $e)
51
+        catch (LaravelInvitesException $e)
52 52
         {
53 53
             $this->error($e->getMessage());
54 54
         }
Please login to merge, or discard this 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/Mail/InvitationMail.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
             'code' => (string) $this->invite->code
40 40
         ];
41 41
 
42
-        if($this->invite->valid_upto)
42
+        if ($this->invite->valid_upto)
43 43
         {
44 44
             $url = URL::temporarySignedRoute('laravelinvites.routes.follow', $this->invite->valid_upto, $data);
45 45
         }
Please login to merge, or discard this 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/database/migrations/2019_01_22_052953_create_invites_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create(config('laravelinvites.table'), function (Blueprint $table) {
16
+        Schema::create(config('laravelinvites.table'), function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->string('email')->nullable()->unique();
19 19
             $table->string('code')->unique();
Please login to merge, or discard this patch.
src/Models/Invite.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  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))
40
+        if ($this->used_count >= $this->allowed_count && config('laravelinvites.delete_on_full', true))
41 41
             $this->delete();
42 42
     }
43 43
 
44 44
     public function scopeValid($query)
45 45
     {
46
-        return $query->where('valid_from','<=', now())
46
+        return $query->where('valid_from', '<=', now())
47 47
             ->where('valid_upto', '>=', now())
48 48
             ->whereRaw('allowed_count > used_count');
49 49
     }
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
      */
60 60
     private function setDefaultExpiry()
61 61
     {
62
-        if(config('laravelinvites.expiry.type')==='none')
62
+        if (config('laravelinvites.expiry.type') === 'none')
63 63
             return null;
64 64
         
65
-        if(config('laravelinvites.expiry.type') === 'hours')
65
+        if (config('laravelinvites.expiry.type') === 'hours')
66 66
             return now()->addHours(config('laravelinvites.expiry.value'));
67 67
             
68
-        elseif(config('laravelinvites.expiry.type') === "days")
68
+        elseif (config('laravelinvites.expiry.type') === "days")
69 69
             return now()->addDays(config('laravelinvites.expiry.days'));
70 70
     }
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this 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 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct($email, $valid_email)
10 10
     {
11
-        if($email)
11
+        if ($email)
12 12
             parent::__construct("This invitation code is not valid with this $email");
13 13
         else
14 14
             parent::__construct("This invitation code is valid only for $valid_email");
Please login to merge, or discard this 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/Commands/GenerateInvitations.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,17 +43,17 @@
 block discarded – undo
43 43
      */
44 44
     public function handle()
45 45
     {
46
-        $email = $this->argument('email') ? : null;
46
+        $email = $this->argument('email') ?: null;
47 47
         $allow = $this->option('allow');
48 48
         $count = $this->option('count');
49 49
         $hours = (int) $this->option('hours');
50 50
         $days = (int) $this->option('days');
51 51
 
52
-        $invite = LaravelInvites::for($email)->allow($allow);
52
+        $invite = LaravelInvites::for ($email)->allow($allow);
53 53
 
54
-        if($days)
54
+        if ($days)
55 55
             $invite->setExpiry(now()->addDays($days));
56
-        else if($hours)
56
+        else if ($hours)
57 57
             $invite->setExpiry(now()->addHours($hours));
58 58
 
59 59
         $invite->generate($count);
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,12 +49,15 @@
 block discarded – undo
49 49
         $hours = (int) $this->option('hours');
50 50
         $days = (int) $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
         $invite->generate($count);
60 63
 
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
@@ -47,10 +47,11 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function get()
49 49
     {
50
-        if (!blank(optional($this->data)['email']))
51
-            $result = Invite::valid()->whereEmail($this->data['email'])->first();
52
-        else
53
-            $result = Invite::valid()->get();
50
+        if (!blank(optional($this->data)['email'])) {
51
+                    $result = Invite::valid()->whereEmail($this->data['email'])->first();
52
+        } else {
53
+                    $result = Invite::valid()->get();
54
+        }
54 55
 
55 56
         $this->initializeData();
56 57
 
@@ -75,8 +76,9 @@  discard block
 block discarded – undo
75 76
         $validator = Validator::make(compact('email'), [
76 77
             'email'=>'required|email'
77 78
         ]);
78
-        if ($validator->fails())
79
-            throw new InvalidEmailIdException;
79
+        if ($validator->fails()) {
80
+                    throw new InvalidEmailIdException;
81
+        }
80 82
 
81 83
         $this->data['email'] = $email;
82 84
 
@@ -92,8 +94,9 @@  discard block
 block discarded – undo
92 94
     {
93 95
         $invite = Invite::create($this->data);
94 96
 
95
-        if ($invite->email && config('laravelinvites.mail.enabled', true))
96
-            Mail::to($invite->email)->send(new InvitationMail($invite));
97
+        if ($invite->email && config('laravelinvites.mail.enabled', true)) {
98
+                    Mail::to($invite->email)->send(new InvitationMail($invite));
99
+        }
97 100
 
98 101
         return $invite;
99 102
     }
@@ -118,8 +121,9 @@  discard block
 block discarded – undo
118 121
      */
119 122
     private function prepare()
120 123
     {
121
-        if ($this->number_of_invites == 1)
122
-            return $this->prepareSingle();
124
+        if ($this->number_of_invites == 1) {
125
+                    return $this->prepareSingle();
126
+        }
123 127
 
124 128
         $invites = [];
125 129
 
@@ -142,15 +146,17 @@  discard block
 block discarded – undo
142 146
     {
143 147
         if (optional($this->data)['email'] && !blank($this->data['email']))
144 148
         {
145
-            if ($number_of_invites > 1)
146
-                throw new AnEmailCanHaveOnlyOneInvitation;
149
+            if ($number_of_invites > 1) {
150
+                            throw new AnEmailCanHaveOnlyOneInvitation;
151
+            }
147 152
 
148 153
             $validator = Validator::make($this->data, [
149 154
                 'email'=>'unique:'.config('laravelinvites.table').',email'
150 155
             ]);
151 156
 
152
-            if ($validator->fails())
153
-                throw new AnEmailCanHaveOnlyOneInvitation;
157
+            if ($validator->fails()) {
158
+                            throw new AnEmailCanHaveOnlyOneInvitation;
159
+            }
154 160
         }
155 161
     }
156 162
 
@@ -272,28 +278,23 @@  discard block
 block discarded – undo
272 278
 
273 279
             $this->check($value, $email);
274 280
             return true;
275
-        }
276
-        catch (InvalidInvitationCodeException $e)
281
+        } catch (InvalidInvitationCodeException $e)
277 282
         {
278 283
             $validator->errors()->add($emailFieldName, ':attribute is invalid');
279 284
             return false;
280
-        }
281
-        catch (InvitationNotYetActiveException $e)
285
+        } catch (InvitationNotYetActiveException $e)
282 286
         {
283 287
             $validator->errors()->add($emailFieldName, ':attribute is not valid yet');
284 288
             return false;
285
-        }
286
-        catch (InvitationExpiredException $e)
289
+        } catch (InvitationExpiredException $e)
287 290
         {
288 291
             $validator->errors()->add($emailFieldName, ':attribute expired');
289 292
             return false;
290
-        }
291
-        catch (InvitationNotValidWithEmailException $e)
293
+        } catch (InvitationNotValidWithEmailException $e)
292 294
         {
293 295
             $validator->errors()->add($emailFieldName, ':attribute is not valid with the provided '.$emailFieldName);
294 296
             return false;
295
-        }
296
-        catch (MaximumUseOfCodeException $e)
297
+        } catch (MaximumUseOfCodeException $e)
297 298
         {
298 299
             $validator->errors()->add($emailFieldName, ':attribute has been used for the maximum possible times');
299 300
             return false;
@@ -316,8 +317,7 @@  discard block
 block discarded – undo
316 317
             $this->check($code, $email);
317 318
 
318 319
             return true;
319
-        }
320
-        catch (LaravelInvitesException $e)
320
+        } catch (LaravelInvitesException $e)
321 321
         {
322 322
             return false;
323 323
         }
@@ -335,20 +335,25 @@  discard block
 block discarded – undo
335 335
     {
336 336
         $invite = Invite::whereCode($code)->first();
337 337
 
338
-        if (!$invite)
339
-            throw new InvalidInvitationCodeException;
338
+        if (!$invite) {
339
+                    throw new InvalidInvitationCodeException;
340
+        }
340 341
         
341
-        if ($invite->valid_from > now())
342
-            throw new InvitationNotYetActiveException($invite->valid_from);
342
+        if ($invite->valid_from > now()) {
343
+                    throw new InvitationNotYetActiveException($invite->valid_from);
344
+        }
343 345
 
344
-        if ($invite->valid_upto && $invite->valid_upto <= now())
345
-            throw new InvitationExpiredException($invite->valid_upto);
346
+        if ($invite->valid_upto && $invite->valid_upto <= now()) {
347
+                    throw new InvitationExpiredException($invite->valid_upto);
348
+        }
346 349
 
347
-        if ($invite->used_count > ($invite->allowed_count - 1))
348
-            throw new MaximumUseOfCodeException($invite->allowed_count);
350
+        if ($invite->used_count > ($invite->allowed_count - 1)) {
351
+                    throw new MaximumUseOfCodeException($invite->allowed_count);
352
+        }
349 353
 
350
-        if ($invite->email !== $email && !blank($invite->email))
351
-            throw new InvitationNotValidWithEmailException($email, $invite->email);
354
+        if ($invite->email !== $email && !blank($invite->email)) {
355
+                    throw new InvitationNotValidWithEmailException($email, $invite->email);
356
+        }
352 357
 
353 358
         return true;
354 359
     }
Please login to merge, or discard this patch.