Passed
Push — master ( 1402e3...740cbb )
by Vinicius Lourenço
03:23
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/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   +36 added lines, -24 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function hasScheduleBetween($model_type, $start_at, $end_at)
49 49
     {
50
-        if(!Config::get('scheduler.enable_schedule_conflict'))
51
-            return false;
50
+        if(!Config::get('scheduler.enable_schedule_conflict')) {
51
+                    return false;
52
+        }
52 53
 
53 54
         return !is_null(
54 55
             Schedule::latest()
@@ -103,23 +104,27 @@  discard block
 block discarded – undo
103 104
                 $start = Carbon::parse($schedule->start_at);
104 105
                 $begin = Carbon::parse($start->toDateString());
105 106
 
106
-                if($begin->greaterThan($today))
107
-                    break;
107
+                if($begin->greaterThan($today)) {
108
+                                    break;
109
+                }
108 110
 
109
-                if($begin->notEqualTo($today))
110
-                    continue;
111
+                if($begin->notEqualTo($today)) {
112
+                                    continue;
113
+                }
111 114
 
112 115
                 $end = Carbon::parse($schedule->end_at);
113 116
 
114
-                if($this->isShouldntAdd($opening, $closing, $start, $end))
115
-                    $add = false;
117
+                if($this->isShouldntAdd($opening, $closing, $start, $end)) {
118
+                                    $add = false;
119
+                }
116 120
             }
117 121
 
118
-            if($add && $closing->lessThanOrEqualTo($closingTime))
119
-                $livres[] = [
122
+            if($add && $closing->lessThanOrEqualTo($closingTime)) {
123
+                            $livres[] = [
120 124
                     'start_at' => $opening,
121 125
                     'end_at' => $closing
122 126
                 ];
127
+            }
123 128
 
124 129
             $openingTime->addMinutes($durationMinutes);
125 130
         }
@@ -156,20 +161,23 @@  discard block
 block discarded – undo
156 161
      */
157 162
     public function validateSchedule($model_type, $start_at, $end_at = null, $status = null)
158 163
     {
159
-        if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at))
160
-            throw new CantAddWithoutEnd;
164
+        if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at)) {
165
+                    throw new CantAddWithoutEnd;
166
+        }
161 167
 
162 168
         $start_at  = $this->parseToCarbon($start_at);
163 169
 
164 170
         if(!is_null($end_at)) {
165 171
             $end_at = $this->parseToCarbon($end_at, $start_at);
166 172
 
167
-            if($start_at->greaterThan($end_at))
168
-                throw new EndCantBeforeStart;
173
+            if($start_at->greaterThan($end_at)) {
174
+                            throw new EndCantBeforeStart;
175
+            }
169 176
         }
170 177
 
171
-        if($this->hasScheduleBetween($model_type, $start_at, $end_at ?? $start_at))
172
-            throw new CantAddWithSameStartAt;
178
+        if($this->hasScheduleBetween($model_type, $start_at, $end_at ?? $start_at)) {
179
+                    throw new CantAddWithSameStartAt;
180
+        }
173 181
 
174 182
         return compact('model_type', 'start_at', 'end_at', 'status');
175 183
     }
@@ -185,14 +193,17 @@  discard block
 block discarded – undo
185 193
      */
186 194
     public function parseToCarbon($date, $reference = null)
187 195
     {
188
-        if($date instanceof Carbon)
189
-            return $date;
196
+        if($date instanceof Carbon) {
197
+                    return $date;
198
+        }
190 199
 
191
-        if(is_string($date))
192
-            return Carbon::parse($date);
200
+        if(is_string($date)) {
201
+                    return Carbon::parse($date);
202
+        }
193 203
 
194
-        if(is_int($date) && !is_null($reference))
195
-            return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
204
+        if(is_int($date) && !is_null($reference)) {
205
+                    return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
206
+        }
196 207
 
197 208
         throw new IntInvalidArgument;
198 209
     }
@@ -205,8 +216,9 @@  discard block
 block discarded – undo
205 216
      */
206 217
     public function parseToSchedule($value)
207 218
     {
208
-        if(is_int($value))
209
-            return Schedule::find($value);
219
+        if(is_int($value)) {
220
+                    return Schedule::find($value);
221
+        }
210 222
 
211 223
         return Schedule::byStartAt($value)->first();
212 224
     }
Please login to merge, or discard this patch.
src/Scheduler/Traits/SchedulerModelTrait.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -110,16 +110,19 @@
 block discarded – undo
110 110
 	 */
111 111
 	public function removeSchedule($schedule)
112 112
 	{
113
-		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
114
-			throw new CantRemoveByDate;
113
+		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) {
114
+					throw new CantRemoveByDate;
115
+		}
115 116
 
116 117
 		$schedule = Scheduler::parseToSchedule($schedule);
117 118
 
118
-		if(!($schedule instanceof Model))
119
-			throw (new ModelNotFound)->setValues(Schedule::class);
119
+		if(!($schedule instanceof Model)) {
120
+					throw (new ModelNotFound)->setValues(Schedule::class);
121
+		}
120 122
 
121
-		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey())
122
-			throw new DoesNotBelong;
123
+		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey()) {
124
+					throw new DoesNotBelong;
125
+		}
123 126
 
124 127
 		return $schedule->delete();
125 128
 	}
Please login to merge, or discard this patch.