Test Failed
Push — master ( 3ea7c5...de62e4 )
by Vinicius Lourenço
03:18
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   +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.
src/Scheduler/Scheduler.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -84,29 +84,34 @@
 block discarded – undo
84 84
             $add = true;
85 85
 
86 86
             foreach (Schedule::orderBy('start_at', 'DESC')->cursor() as $schedule) {
87
-            	if($schedule->model_type != $model_type)
88
-            		continue;
87
+            	if($schedule->model_type != $model_type) {
88
+            	            		continue;
89
+            	}
89 90
 
90 91
                 $start = Carbon::parse($schedule->start_at);
91 92
                 $begin = Carbon::parse($start->toDateString());
92 93
 
93
-                if($begin->greaterThan($today))
94
-                    break;
94
+                if($begin->greaterThan($today)) {
95
+                                    break;
96
+                }
95 97
 
96
-                if($begin->notEqualTo($today))
97
-                    continue;
98
+                if($begin->notEqualTo($today)) {
99
+                                    continue;
100
+                }
98 101
 
99 102
                 $end = Carbon::parse($schedule->end_at);
100 103
                 if($start <= Carbon::parse($openingTime->toDateTimeString())
101
-                && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes))
102
-                    $add = false;
104
+                && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)) {
105
+                                    $add = false;
106
+                }
103 107
             }
104 108
 
105
-            if($add)
106
-                $livres[] = [
109
+            if($add) {
110
+                            $livres[] = [
107 111
                     'start_at' => Carbon::parse($openingTime->toDateTimeString()),
108 112
                     'end_at' => Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)
109 113
                 ];
114
+            }
110 115
 
111 116
             $openingTime->addMinutes($durationMinutes);
112 117
         }
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
@@ -52,13 +52,15 @@
 block discarded – undo
52 52
      */
53 53
     public function parseStatusKey($key)
54 54
     {
55
-    	if(is_int($key))
56
-    		return ['status' => $key];
55
+    	if(is_int($key)) {
56
+    	    		return ['status' => $key];
57
+    	}
57 58
 
58 59
     	$status = ScheduleStatus::where('name', $key)->first();
59 60
 
60
-    	if(is_null($status))
61
-    		throw (new ModelNotFound)->setValues(ScheduleStatus::class);
61
+    	if(is_null($status)) {
62
+    	    		throw (new ModelNotFound)->setValues(ScheduleStatus::class);
63
+    	}
62 64
 
63 65
     	return ['status' => $status->id];
64 66
     }
Please login to merge, or discard this patch.