Passed
Push — master ( 72070c...1d1702 )
by Vinicius Lourenço
03:38
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   +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.
src/Scheduler/Scheduler.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function hasScheduleBetween($model_type, $start_at, $end_at)
44 44
     {
45
-        if(!Config::get('scheduler.enable_schedule_conflict'))
46
-            return false;
45
+        if(!Config::get('scheduler.enable_schedule_conflict')) {
46
+                    return false;
47
+        }
47 48
 
48 49
         return !is_null(
49 50
             Schedule::latest()
@@ -88,29 +89,34 @@  discard block
 block discarded – undo
88 89
             $add = true;
89 90
 
90 91
             foreach (Schedule::orderBy('start_at', 'DESC')->cursor() as $schedule) {
91
-            	if($schedule->model_type != $model_type)
92
-            		continue;
92
+            	if($schedule->model_type != $model_type) {
93
+            	            		continue;
94
+            	}
93 95
 
94 96
                 $start = Carbon::parse($schedule->start_at);
95 97
                 $begin = Carbon::parse($start->toDateString());
96 98
 
97
-                if($begin->greaterThan($today))
98
-                    break;
99
+                if($begin->greaterThan($today)) {
100
+                                    break;
101
+                }
99 102
 
100
-                if($begin->notEqualTo($today))
101
-                    continue;
103
+                if($begin->notEqualTo($today)) {
104
+                                    continue;
105
+                }
102 106
 
103 107
                 $end = Carbon::parse($schedule->end_at);
104 108
                 if($start <= Carbon::parse($openingTime->toDateTimeString())
105
-                && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes))
106
-                    $add = false;
109
+                && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)) {
110
+                                    $add = false;
111
+                }
107 112
             }
108 113
 
109
-            if($add)
110
-                $livres[] = [
114
+            if($add) {
115
+                            $livres[] = [
111 116
                     'start_at' => Carbon::parse($openingTime->toDateTimeString()),
112 117
                     'end_at' => Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)
113 118
                 ];
119
+            }
114 120
 
115 121
             $openingTime->addMinutes($durationMinutes);
116 122
         }
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
@@ -69,17 +69,20 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function addSchedule($start_at, $end_at = null, $status = null)
71 71
 	{
72
-		if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at))
73
-			throw new CantAddWithoutEnd;
72
+		if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at)) {
73
+					throw new CantAddWithoutEnd;
74
+		}
74 75
 
75 76
 		$start_at  = $this->parseToCarbon($start_at);
76 77
 		$end_at = $this->parseToCarbon($end_at, $start_at);
77 78
 
78
-		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at))
79
-			throw new CantAddWithSameStartAt;
79
+		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at)) {
80
+					throw new CantAddWithSameStartAt;
81
+		}
80 82
 
81
-		if($start_at->greaterThan($end_at) && !is_null($end_at))
82
-			throw new EndCantBeforeStart;
83
+		if($start_at->greaterThan($end_at) && !is_null($end_at)) {
84
+					throw new EndCantBeforeStart;
85
+		}
83 86
 
84 87
 		$model_id = $this->getKey();
85 88
 		$model_type = self::class;
@@ -96,11 +99,13 @@  discard block
 block discarded – undo
96 99
 	 */
97 100
 	public function parseToCarbon($date, $reference = null)
98 101
 	{
99
-		if(is_string($date))
100
-			return Carbon::parse($date);
102
+		if(is_string($date)) {
103
+					return Carbon::parse($date);
104
+		}
101 105
 
102
-		if(is_int($date))
103
-			return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
106
+		if(is_int($date)) {
107
+					return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
108
+		}
104 109
 
105 110
 		return $date;
106 111
 	}
@@ -113,11 +118,13 @@  discard block
 block discarded – undo
113 118
 	 */
114 119
 	public function parseToSchedule($value)
115 120
 	{
116
-		if(is_int($value))
117
-			return Schedule::find($value);
121
+		if(is_int($value)) {
122
+					return Schedule::find($value);
123
+		}
118 124
 
119
-		if(is_string($value) || $value instanceof Carbon)
120
-			return Schedule::byStartAt($value)->first();
125
+		if(is_string($value) || $value instanceof Carbon) {
126
+					return Schedule::byStartAt($value)->first();
127
+		}
121 128
 
122 129
 		return null;
123 130
 	}
@@ -136,16 +143,19 @@  discard block
 block discarded – undo
136 143
 	 */
137 144
 	public function removeSchedule($schedule)
138 145
 	{
139
-		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
140
-			throw new CantRemoveByDate;
146
+		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) {
147
+					throw new CantRemoveByDate;
148
+		}
141 149
 
142 150
 		$schedule = $this->parseToSchedule($schedule);
143 151
 
144
-		if(!($schedule instanceof Model))
145
-			throw (new ModelNotFound)->setValues(Schedule::class);
152
+		if(!($schedule instanceof Model)) {
153
+					throw (new ModelNotFound)->setValues(Schedule::class);
154
+		}
146 155
 
147
-		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey())
148
-			throw new DoesNotBelong;
156
+		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey()) {
157
+					throw new DoesNotBelong;
158
+		}
149 159
 
150 160
 		return $schedule->delete();
151 161
 	}
Please login to merge, or discard this patch.