Passed
Branch master (3ea7c5)
by Vinicius Lourenço
06:59
created
src/Scheduler/Scheduler.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,23 +87,27 @@
 block discarded – undo
87 87
                 $start = Carbon::parse($schedule->start_at);
88 88
                 $begin = Carbon::parse($start->toDateString());
89 89
 
90
-                if($begin->greaterThan($today))
91
-                    break;
90
+                if($begin->greaterThan($today)) {
91
+                                    break;
92
+                }
92 93
 
93
-                if($begin->notEqualTo($today))
94
-                    continue;
94
+                if($begin->notEqualTo($today)) {
95
+                                    continue;
96
+                }
95 97
 
96 98
                 $end = Carbon::parse($schedule->end_at);
97 99
                 if($start <= Carbon::parse($openingTime->toDateTimeString())
98
-                && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes))
99
-                    $add = false;
100
+                && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)) {
101
+                                    $add = false;
102
+                }
100 103
             }
101 104
 
102
-            if($add)
103
-                $livres[] = [
105
+            if($add) {
106
+                            $livres[] = [
104 107
                     'start_at' => Carbon::parse($openingTime->toDateTimeString()),
105 108
                     'end_at' => Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)
106 109
                 ];
110
+            }
107 111
 
108 112
             $openingTime->addMinutes($durationMinutes);
109 113
         }
Please login to merge, or discard this patch.
src/Scheduler/Exceptions/CustomException.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,8 +88,9 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function parseValues()
90 90
     {
91
-        if(is_array($this->attributes) && is_array($this->values))
92
-            return collect($this->attributes)->combine($this->values)->all();
91
+        if(is_array($this->attributes) && is_array($this->values)) {
92
+                    return collect($this->attributes)->combine($this->values)->all();
93
+        }
93 94
 
94 95
         return [ $this->attributes => $this->values ?? $this->isLower() ];
95 96
     }
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
      */
112 113
     protected function getAlias()
113 114
     {
114
-        if(is_object($this->model))
115
-            $this->model = get_class($this->model);
115
+        if(is_object($this->model)) {
116
+                    $this->model = get_class($this->model);
117
+        }
116 118
 
117 119
         return collect(trans('scheduler::exceptions.aliases.'. $this->aliastype))->search($this->model) ?: 'Recurso';
118 120
     }
Please login to merge, or discard this patch.
src/Scheduler/Models/Schedule.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,13 +51,15 @@
 block discarded – undo
51 51
      */
52 52
     public function parseStatusKey($key)
53 53
     {
54
-    	if(is_int($key))
55
-    		return ['status' => $key];
54
+    	if(is_int($key)) {
55
+    	    		return ['status' => $key];
56
+    	}
56 57
 
57 58
     	$status = ScheduleStatus::where('name', $name)->first();
58 59
 
59
-    	if(is_null($status))
60
-    		throw (new ModelNotFoundException)->setModel(ScheduleStatus::class, $name);
60
+    	if(is_null($status)) {
61
+    	    		throw (new ModelNotFoundException)->setModel(ScheduleStatus::class, $name);
62
+    	}
61 63
 
62 64
     	return ['status' => $status->id];
63 65
     }
Please login to merge, or discard this patch.
src/Scheduler/Traits/SchedulerModelTrait.php 1 patch
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -51,24 +51,30 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function addSchedule($start_at, $end_at = null, $status = null)
53 53
 	{
54
-		if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at))
55
-			throw new CantAddWithoutEnd;
54
+		if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at)) {
55
+					throw new CantAddWithoutEnd;
56
+		}
56 57
 
57
-		if(is_string($start_at))
58
-			$start_at = Carbon::parse($start_at);
58
+		if(is_string($start_at)) {
59
+					$start_at = Carbon::parse($start_at);
60
+		}
59 61
 
60
-		if(is_string($end_at))
61
-			$end_at = Carbon::parse($end_at);
62
+		if(is_string($end_at)) {
63
+					$end_at = Carbon::parse($end_at);
64
+		}
62 65
 
63
-		if(is_int($end_at))
64
-			$end_at = Carbon::parse($start_at->toDateTimeString())->addMinutes($end_at);
66
+		if(is_int($end_at)) {
67
+					$end_at = Carbon::parse($start_at->toDateTimeString())->addMinutes($end_at);
68
+		}
65 69
 
66
-		if(Config::get('scheduler.enable_schedule_conflict'))
67
-			if(Scheduler::hasScheduleBetween($start_at, $end_at ?? $start_at))
70
+		if(Config::get('scheduler.enable_schedule_conflict')) {
71
+					if(Scheduler::hasScheduleBetween($start_at, $end_at ?? $start_at))
68 72
 				throw new CantAddWithSameStartAt;
73
+		}
69 74
 
70
-		if($start_at->greaterThan($end_at) && !is_null($end_at))
71
-			throw new EndCantBeforeStart;
75
+		if($start_at->greaterThan($end_at) && !is_null($end_at)) {
76
+					throw new EndCantBeforeStart;
77
+		}
72 78
 
73 79
 		$model_id = $this->getKey();
74 80
 		$model_type = self::class;
@@ -90,20 +96,25 @@  discard block
 block discarded – undo
90 96
 	 */
91 97
 	public function removeSchedule($schedule)
92 98
 	{
93
-		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
94
-			throw new CantRemoveByDate;
99
+		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) {
100
+					throw new CantRemoveByDate;
101
+		}
95 102
 
96
-		if(is_int($schedule))
97
-			$schedule = Schedule::find($schedule);
103
+		if(is_int($schedule)) {
104
+					$schedule = Schedule::find($schedule);
105
+		}
98 106
 
99
-		if(is_string($schedule) || $schedule instanceof Carbon)
100
-			$schedule = Schedule::byStartAt($schedule)->first();
107
+		if(is_string($schedule) || $schedule instanceof Carbon) {
108
+					$schedule = Schedule::byStartAt($schedule)->first();
109
+		}
101 110
 
102
-		if(!($schedule instanceof Model))
103
-			throw (new ModelNotFound)->setValues(Schedule::class);
111
+		if(!($schedule instanceof Model)) {
112
+					throw (new ModelNotFound)->setValues(Schedule::class);
113
+		}
104 114
 
105
-		if($schedule->model_type != self::class)
106
-			throw new DoesNotBelong;
115
+		if($schedule->model_type != self::class) {
116
+					throw new DoesNotBelong;
117
+		}
107 118
 
108 119
 		return $schedule->delete();
109 120
 	}
Please login to merge, or discard this patch.