Passed
Push — master ( 1d1702...566365 )
by Vinicius Lourenço
03:40
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   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -69,20 +69,23 @@  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
 
77 78
 		if(!is_null($end_at)) {
78 79
 			$end_at = $this->parseToCarbon($end_at, $start_at);
79 80
 
80
-			if($start_at->greaterThan($end_at))
81
-				throw new EndCantBeforeStart;
81
+			if($start_at->greaterThan($end_at)) {
82
+							throw new EndCantBeforeStart;
83
+			}
82 84
 		}
83 85
 
84
-		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at))
85
-			throw new CantAddWithSameStartAt;
86
+		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at)) {
87
+					throw new CantAddWithSameStartAt;
88
+		}
86 89
 
87 90
 		$model_id = $this->getKey();
88 91
 		$model_type = self::class;
@@ -99,11 +102,13 @@  discard block
 block discarded – undo
99 102
 	 */
100 103
 	public function parseToCarbon($date, $reference = null)
101 104
 	{
102
-		if(is_string($date))
103
-			return Carbon::parse($date);
105
+		if(is_string($date)) {
106
+					return Carbon::parse($date);
107
+		}
104 108
 
105
-		if(is_int($date) && !is_null($reference))
106
-			return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
109
+		if(is_int($date) && !is_null($reference)) {
110
+					return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
111
+		}
107 112
 
108 113
 		return $date;
109 114
 	}
@@ -116,8 +121,9 @@  discard block
 block discarded – undo
116 121
 	 */
117 122
 	public function parseToSchedule($value)
118 123
 	{
119
-		if(is_int($value))
120
-			return Schedule::find($value);
124
+		if(is_int($value)) {
125
+					return Schedule::find($value);
126
+		}
121 127
 
122 128
 		return Schedule::byStartAt($value)->first();
123 129
 	}
@@ -136,16 +142,19 @@  discard block
 block discarded – undo
136 142
 	 */
137 143
 	public function removeSchedule($schedule)
138 144
 	{
139
-		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
140
-			throw new CantRemoveByDate;
145
+		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) {
146
+					throw new CantRemoveByDate;
147
+		}
141 148
 
142 149
 		$schedule = $this->parseToSchedule($schedule);
143 150
 
144
-		if(!($schedule instanceof Model))
145
-			throw (new ModelNotFound)->setValues(Schedule::class);
151
+		if(!($schedule instanceof Model)) {
152
+					throw (new ModelNotFound)->setValues(Schedule::class);
153
+		}
146 154
 
147
-		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey())
148
-			throw new DoesNotBelong;
155
+		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey()) {
156
+					throw new DoesNotBelong;
157
+		}
149 158
 
150 159
 		return $schedule->delete();
151 160
 	}
Please login to merge, or discard this patch.