Passed
Push — master ( 1d1702...566365 )
by Vinicius Lourenço
03:40
created
src/Scheduler/Models/Schedule.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      *
40 40
      * @param int|string $status Pode ser passado o ID do status ou seu nome para seta-lo no horário.
41 41
      */
42
-    public function setStatus($name)
42
+    public function setStatus ($name)
43 43
     {
44 44
     	$this->fill($this->parseStatusKey($name))->save();
45 45
     }
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
      * @param  int|string $key ID ou o nome do status.
51 51
      * @return array
52 52
      */
53
-    public function parseStatusKey($key)
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
     	$status = ScheduleStatus::where('name', $key)->first();
59 59
 
60
-    	if(is_null($status))
60
+    	if (is_null($status))
61 61
     		throw (new ModelNotFound)->setValues(ScheduleStatus::class);
62 62
 
63
-    	return ['status' => $status->id];
63
+    	return [ 'status' => $status->id ];
64 64
     }
65 65
 
66 66
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param \Carbon\Carbon|string $start_at
71 71
      * @return \Illuminate\Database\Eloquent\Builder
72 72
      */
73
-    public function scopeByStartAt($query, $start_at)
73
+    public function scopeByStartAt ($query, $start_at)
74 74
     {
75 75
         return $query->where('start_at', $start_at);
76 76
     }
Please login to merge, or discard this patch.
src/Scheduler/Traits/SchedulerModelTrait.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -35,21 +35,21 @@  discard block
 block discarded – undo
35 35
      * @param  string  $relation
36 36
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
37 37
      */
38
-	abstract public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null);
38
+	abstract public function belongsTo ($related, $foreignKey = null, $ownerKey = null, $relation = null);
39 39
 
40 40
 	/**
41 41
      * Get the value of the model's primary key.
42 42
      *
43 43
      * @return mixed
44 44
      */
45
-	abstract public function getKey();
45
+	abstract public function getKey ();
46 46
 
47 47
 	/**
48 48
      * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait].
49 49
      *
50 50
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
51 51
      */
52
-	public function schedules()
52
+	public function schedules ()
53 53
 	{
54 54
 		return $this->belongsTo(Config::get('scheduler.schedules_table'), 'model_id');
55 55
 	}
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
 	 * @throws \H4ad\Scheduler\Exceptions\EndCantBeforeStart
68 68
 	 * @throws \H4ad\Scheduler\Exceptions\CantAddWithSameStartAt
69 69
 	 */
70
-	public function addSchedule($start_at, $end_at = null, $status = null)
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))
72
+		if (!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at))
73 73
 			throw new CantAddWithoutEnd;
74 74
 
75
-		$start_at  = $this->parseToCarbon($start_at);
75
+		$start_at = $this->parseToCarbon($start_at);
76 76
 
77
-		if(!is_null($end_at)) {
77
+		if (!is_null($end_at)) {
78 78
 			$end_at = $this->parseToCarbon($end_at, $start_at);
79 79
 
80
-			if($start_at->greaterThan($end_at))
80
+			if ($start_at->greaterThan($end_at))
81 81
 				throw new EndCantBeforeStart;
82 82
 		}
83 83
 
84
-		if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at))
84
+		if (Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at))
85 85
 			throw new CantAddWithSameStartAt;
86 86
 
87 87
 		$model_id = $this->getKey();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @param  \Carbon\Carbon $reference Data de referencia quando o [date] é inteiro.
98 98
 	 * @return \Carbon\Carbon
99 99
 	 */
100
-	public function parseToCarbon($date, $reference = null)
100
+	public function parseToCarbon ($date, $reference = null)
101 101
 	{
102
-		if(is_string($date))
102
+		if (is_string($date))
103 103
 			return Carbon::parse($date);
104 104
 
105
-		if(is_int($date) && !is_null($reference))
105
+		if (is_int($date) && !is_null($reference))
106 106
 			return Carbon::parse($reference->toDateTimeString())->addMinutes($date);
107 107
 
108 108
 		return $date;
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 	 * @param  \Carbon\Carbon|string|int $value Valor que representará a data ou o id a ser buscado.
115 115
 	 * @return \H4ad\Scheduler\Models\Schedule|null
116 116
 	 */
117
-	public function parseToSchedule($value)
117
+	public function parseToSchedule ($value)
118 118
 	{
119
-		if(is_int($value))
119
+		if (is_int($value))
120 120
 			return Schedule::find($value);
121 121
 
122 122
 		return Schedule::byStartAt($value)->first();
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 * @throws \H4ad\Scheduler\Exceptions\CantRemoveByDate
135 135
 	 * @throws \H4ad\Scheduler\Exceptions\ModelNotFound
136 136
 	 */
137
-	public function removeSchedule($schedule)
137
+	public function removeSchedule ($schedule)
138 138
 	{
139
-		if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
139
+		if (!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule))
140 140
 			throw new CantRemoveByDate;
141 141
 
142 142
 		$schedule = $this->parseToSchedule($schedule);
143 143
 
144
-		if(!($schedule instanceof Model))
144
+		if (!($schedule instanceof Model))
145 145
 			throw (new ModelNotFound)->setValues(Schedule::class);
146 146
 
147
-		if($schedule->model_type != self::class || $schedule->model_id != $this->getKey())
147
+		if ($schedule->model_type != self::class || $schedule->model_id != $this->getKey())
148 148
 			throw new DoesNotBelong;
149 149
 
150 150
 		return $schedule->delete();
Please login to merge, or discard this patch.