@@ -38,11 +38,11 @@ |
||
| 38 | 38 | $hoursAgo = $lastDeletedAt == null ? null : $lastDeletedAt->diffInHours(now()); |
| 39 | 39 | |
| 40 | 40 | // Delete the cooldowns if the last run was 24 hours ago or more |
| 41 | - if($hoursAgo >= 24 || $hoursAgo == null) { |
|
| 41 | + if ($hoursAgo >= 24 || $hoursAgo == null) { |
|
| 42 | 42 | try { |
| 43 | 43 | Cooldown::expired()->delete(); |
| 44 | 44 | } |
| 45 | - catch(Exception $e) { } |
|
| 45 | + catch (Exception $e) { } |
|
| 46 | 46 | |
| 47 | 47 | Cache::forever('kurozora_cooldown_last_cleaned_up_at', now()); |
| 48 | 48 | } |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | if($hoursAgo >= 24 || $hoursAgo == null) { |
| 42 | 42 | try { |
| 43 | 43 | Cooldown::expired()->delete(); |
| 44 | - } |
|
| 45 | - catch(Exception $e) { } |
|
| 44 | + } catch(Exception $e) { } |
|
| 46 | 45 | |
| 47 | 46 | Cache::forever('kurozora_cooldown_last_cleaned_up_at', now()); |
| 48 | 47 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Kurozora\Cooldown\Support\PendingCooldown; |
| 4 | 4 | |
| 5 | -if(!function_exists('cooldown')) |
|
| 5 | +if (!function_exists('cooldown')) |
|
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | 8 | * @param string $name |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | class Cooldown extends Model |
| 8 | 8 | { |
| 9 | 9 | protected $table = 'kurozora_cooldowns'; |
| 10 | - protected $guarded = []; |
|
| 10 | + protected $guarded = [ ]; |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * The attributes that should be mutated to dates. |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param string $time |
| 35 | 35 | * @return Cooldown |
| 36 | 36 | */ |
| 37 | - public function for($time) |
|
| 37 | + public function for ($time) |
|
| 38 | 38 | { |
| 39 | 39 | $date = now()->add($time); |
| 40 | 40 | |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $cooldown = $this->findCooldownWithName($this->name); |
| 61 | 61 | |
| 62 | - if(!$cooldown) return; |
|
| 62 | + if (!$cooldown) return; |
|
| 63 | 63 | |
| 64 | 64 | try { |
| 65 | 65 | $cooldown->delete(); |
| 66 | 66 | } |
| 67 | - catch(Exception $e) { } |
|
| 67 | + catch (Exception $e) { } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $cooldown = $this->findCooldownWithName($this->name); |
| 78 | 78 | |
| 79 | - if(!$cooldown) |
|
| 79 | + if (!$cooldown) |
|
| 80 | 80 | return true; |
| 81 | 81 | |
| 82 | - if(now() < $cooldown->expires_at) |
|
| 82 | + if (now() < $cooldown->expires_at) |
|
| 83 | 83 | return false; |
| 84 | 84 | |
| 85 | 85 | try { |
| 86 | 86 | $cooldown->delete(); |
| 87 | 87 | } |
| 88 | - catch(Exception $e) { } |
|
| 88 | + catch (Exception $e) { } |
|
| 89 | 89 | |
| 90 | 90 | return true; |
| 91 | 91 | } |
@@ -99,16 +99,16 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $cooldown = $this->findCooldownWithName($this->name); |
| 101 | 101 | |
| 102 | - if(!$cooldown) |
|
| 102 | + if (!$cooldown) |
|
| 103 | 103 | return false; |
| 104 | 104 | |
| 105 | - if(now() < $cooldown->expires_at) |
|
| 105 | + if (now() < $cooldown->expires_at) |
|
| 106 | 106 | return true; |
| 107 | 107 | |
| 108 | 108 | try { |
| 109 | 109 | $cooldown->delete(); |
| 110 | 110 | } |
| 111 | - catch(Exception $e) { } |
|
| 111 | + catch (Exception $e) { } |
|
| 112 | 112 | |
| 113 | 113 | return false; |
| 114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function expiresAt() |
| 122 | 122 | { |
| 123 | - if($this->passed()) return null; |
|
| 123 | + if ($this->passed()) return null; |
|
| 124 | 124 | |
| 125 | 125 | $cooldown = $this->findCooldownWithName($this->name); |
| 126 | 126 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | private function createOrUpdateCooldownWithDate($date) |
| 161 | 161 | { |
| 162 | 162 | // Update existing cooldown |
| 163 | - if($cooldown = $this->findCooldownWithName($this->name)) |
|
| 163 | + if ($cooldown = $this->findCooldownWithName($this->name)) |
|
| 164 | 164 | { |
| 165 | 165 | $cooldown->expires_at = $date; |
| 166 | 166 | $cooldown->save(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | private function modelType() |
| 186 | 186 | { |
| 187 | - if($this->model === null) return null; |
|
| 187 | + if ($this->model === null) return null; |
|
| 188 | 188 | |
| 189 | 189 | return get_class($this->model); |
| 190 | 190 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | private function modelId() |
| 198 | 198 | { |
| 199 | - if($this->model === null) return null; |
|
| 199 | + if ($this->model === null) return null; |
|
| 200 | 200 | |
| 201 | 201 | return (int) $this->model->id; |
| 202 | 202 | } |
@@ -59,12 +59,13 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $cooldown = $this->findCooldownWithName($this->name); |
| 61 | 61 | |
| 62 | - if(!$cooldown) return; |
|
| 62 | + if(!$cooldown) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | try { |
| 65 | 67 | $cooldown->delete(); |
| 66 | - } |
|
| 67 | - catch(Exception $e) { } |
|
| 68 | + } catch(Exception $e) { } |
|
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | /** |
@@ -76,16 +77,17 @@ discard block |
||
| 76 | 77 | { |
| 77 | 78 | $cooldown = $this->findCooldownWithName($this->name); |
| 78 | 79 | |
| 79 | - if(!$cooldown) |
|
| 80 | - return true; |
|
| 80 | + if(!$cooldown) { |
|
| 81 | + return true; |
|
| 82 | + } |
|
| 81 | 83 | |
| 82 | - if(now() < $cooldown->expires_at) |
|
| 83 | - return false; |
|
| 84 | + if(now() < $cooldown->expires_at) { |
|
| 85 | + return false; |
|
| 86 | + } |
|
| 84 | 87 | |
| 85 | 88 | try { |
| 86 | 89 | $cooldown->delete(); |
| 87 | - } |
|
| 88 | - catch(Exception $e) { } |
|
| 90 | + } catch(Exception $e) { } |
|
| 89 | 91 | |
| 90 | 92 | return true; |
| 91 | 93 | } |
@@ -99,16 +101,17 @@ discard block |
||
| 99 | 101 | { |
| 100 | 102 | $cooldown = $this->findCooldownWithName($this->name); |
| 101 | 103 | |
| 102 | - if(!$cooldown) |
|
| 103 | - return false; |
|
| 104 | + if(!$cooldown) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 104 | 107 | |
| 105 | - if(now() < $cooldown->expires_at) |
|
| 106 | - return true; |
|
| 108 | + if(now() < $cooldown->expires_at) { |
|
| 109 | + return true; |
|
| 110 | + } |
|
| 107 | 111 | |
| 108 | 112 | try { |
| 109 | 113 | $cooldown->delete(); |
| 110 | - } |
|
| 111 | - catch(Exception $e) { } |
|
| 114 | + } catch(Exception $e) { } |
|
| 112 | 115 | |
| 113 | 116 | return false; |
| 114 | 117 | } |
@@ -120,7 +123,9 @@ discard block |
||
| 120 | 123 | */ |
| 121 | 124 | public function expiresAt() |
| 122 | 125 | { |
| 123 | - if($this->passed()) return null; |
|
| 126 | + if($this->passed()) { |
|
| 127 | + return null; |
|
| 128 | + } |
|
| 124 | 129 | |
| 125 | 130 | $cooldown = $this->findCooldownWithName($this->name); |
| 126 | 131 | |
@@ -184,7 +189,9 @@ discard block |
||
| 184 | 189 | */ |
| 185 | 190 | private function modelType() |
| 186 | 191 | { |
| 187 | - if($this->model === null) return null; |
|
| 192 | + if($this->model === null) { |
|
| 193 | + return null; |
|
| 194 | + } |
|
| 188 | 195 | |
| 189 | 196 | return get_class($this->model); |
| 190 | 197 | } |
@@ -196,7 +203,9 @@ discard block |
||
| 196 | 203 | */ |
| 197 | 204 | private function modelId() |
| 198 | 205 | { |
| 199 | - if($this->model === null) return null; |
|
| 206 | + if($this->model === null) { |
|
| 207 | + return null; |
|
| 208 | + } |
|
| 200 | 209 | |
| 201 | 210 | return (int) $this->model->id; |
| 202 | 211 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('kurozora_cooldowns', function (Blueprint $table) { |
|
| 16 | + Schema::create('kurozora_cooldowns', function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->string('name'); |
| 19 | 19 | $table->nullableMorphs('model'); |