Passed
Push — master ( 1d1702...566365 )
by Vinicius Lourenço
03:40
created
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.