Passed
Push — master ( 2254d8...1402e3 )
by Vinicius Lourenço
02:58
created
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/Traits/SchedulerModelTrait.php 1 patch
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -70,20 +70,23 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function addSchedule($start_at, $end_at = null, $status = null)
72 72
 	{
73
-		if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at))
74
-			throw new CantAddWithoutEnd;
73
+		if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at)) {
74
+					throw new CantAddWithoutEnd;
75
+		}
75 76
 
76 77
 		$start_at  = $this->parseToCarbon($start_at);
77 78
 
78 79
 		if(!is_null($end_at)) {
79 80
 			$end_at = $this->parseToCarbon($end_at, $start_at);
80 81
 
81
-			if($start_at->greaterThan($end_at))
82
-				throw new EndCantBeforeStart;
82
+			if($start_at->greaterThan($end_at)) {
83
+							throw new EndCantBeforeStart;
84
+			}
83 85
 		}
84 86
 
85
-		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at))
86
-			throw new CantAddWithSameStartAt;
87
+		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at)) {
88
+					throw new CantAddWithSameStartAt;
89
+		}
87 90
 
88 91
 		$model_id = $this->getKey();
89 92
 		$model_type = self::class;
@@ -131,14 +134,17 @@  discard block
 block discarded – undo
131 134
 	 */
132 135
 	public function parseToCarbon($date, $reference = null)
133 136
 	{
134
-		if($date instanceof Carbon)
135
-			return $date;
137
+		if($date instanceof Carbon) {
138
+					return $date;
139
+		}
136 140
 
137
-		if(is_string($date))
138
-			return Carbon::parse($date);
141
+		if(is_string($date)) {
142
+					return Carbon::parse($date);
143
+		}
139 144
 
140
-		if(is_int($date) && !is_null($reference))
141
-			return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
145
+		if(is_int($date) && !is_null($reference)) {
146
+					return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
147
+		}
142 148
 
143 149
 		throw new IntInvalidArgument;
144 150
 	}
@@ -151,8 +157,9 @@  discard block
 block discarded – undo
151 157
 	 */
152 158
 	public function parseToSchedule($value)
153 159
 	{
154
-		if(is_int($value))
155
-			return Schedule::find($value);
160
+		if(is_int($value)) {
161
+					return Schedule::find($value);
162
+		}
156 163
 
157 164
 		return Schedule::byStartAt($value)->first();
158 165
 	}
@@ -171,16 +178,19 @@  discard block
 block discarded – undo
171 178
 	 */
172 179
 	public function removeSchedule($schedule)
173 180
 	{
174
-		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
175
-			throw new CantRemoveByDate;
181
+		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) {
182
+					throw new CantRemoveByDate;
183
+		}
176 184
 
177 185
 		$schedule = $this->parseToSchedule($schedule);
178 186
 
179
-		if(!($schedule instanceof Model))
180
-			throw (new ModelNotFound)->setValues(Schedule::class);
187
+		if(!($schedule instanceof Model)) {
188
+					throw (new ModelNotFound)->setValues(Schedule::class);
189
+		}
181 190
 
182
-		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey())
183
-			throw new DoesNotBelong;
191
+		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey()) {
192
+					throw new DoesNotBelong;
193
+		}
184 194
 
185 195
 		return $schedule->delete();
186 196
 	}
Please login to merge, or discard this patch.
src/Scheduler/Models/Schedule.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,14 +59,17 @@
 block discarded – undo
59 59
      */
60 60
     public function parseStatusKey($status)
61 61
     {
62
-    	if(is_int($status))
63
-    		$status =  ScheduleStatus::find($status);
62
+    	if(is_int($status)) {
63
+    	    		$status =  ScheduleStatus::find($status);
64
+    	}
64 65
 
65
-        if(is_string($status))
66
-        	$status = ScheduleStatus::where('name', $status)->first();
66
+        if(is_string($status)) {
67
+                	$status = ScheduleStatus::where('name', $status)->first();
68
+        }
67 69
 
68
-    	if(is_null($status))
69
-    		throw (new ModelNotFound)->setValues(ScheduleStatus::class);
70
+    	if(is_null($status)) {
71
+    	    		throw (new ModelNotFound)->setValues(ScheduleStatus::class);
72
+    	}
70 73
 
71 74
     	return ['status' => $status->id];
72 75
     }
Please login to merge, or discard this patch.
src/Scheduler/Scheduler.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -43,8 +43,9 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function hasScheduleBetween($model_type, $start_at, $end_at)
45 45
     {
46
-        if(!Config::get('scheduler.enable_schedule_conflict'))
47
-            return false;
46
+        if(!Config::get('scheduler.enable_schedule_conflict')) {
47
+                    return false;
48
+        }
48 49
 
49 50
         return !is_null(
50 51
             Schedule::latest()
@@ -99,23 +100,27 @@  discard block
 block discarded – undo
99 100
                 $start = Carbon::parse($schedule->start_at);
100 101
                 $begin = Carbon::parse($start->toDateString());
101 102
 
102
-                if($begin->greaterThan($today))
103
-                    break;
103
+                if($begin->greaterThan($today)) {
104
+                                    break;
105
+                }
104 106
 
105
-                if($begin->notEqualTo($today))
106
-                    continue;
107
+                if($begin->notEqualTo($today)) {
108
+                                    continue;
109
+                }
107 110
 
108 111
                 $end = Carbon::parse($schedule->end_at);
109 112
 
110
-                if($this->isShouldntAdd($opening, $closing, $start, $end))
111
-                    $add = false;
113
+                if($this->isShouldntAdd($opening, $closing, $start, $end)) {
114
+                                    $add = false;
115
+                }
112 116
             }
113 117
 
114
-            if($add && $closing->lessThanOrEqualTo($closingTime))
115
-                $livres[] = [
118
+            if($add && $closing->lessThanOrEqualTo($closingTime)) {
119
+                            $livres[] = [
116 120
                     'start_at' => $opening,
117 121
                     'end_at' => $closing
118 122
                 ];
123
+            }
119 124
 
120 125
             $openingTime->addMinutes($durationMinutes);
121 126
         }
Please login to merge, or discard this patch.