Passed
Pull Request — master (#223)
by
unknown
05:06
created
config/laravel-model-caching.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,6 +10,6 @@
 block discarded – undo
10 10
     'enable-cooldown' => env('MODEL_CACHE_COOLDOWN_ENABLE', true),
11 11
 
12 12
     'cooldown-disable' => [
13
-		//put full qualified classnames here
13
+        //put full qualified classnames here
14 14
     ]
15 15
 ];
Please login to merge, or discard this patch.
src/Console/Commands/Clear.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     {
13 13
         $option = $this->option('model');
14 14
 
15
-        if (! $option) {
15
+        if (!$option) {
16 16
             return $this->flushEntireCache();
17 17
         }
18 18
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $usesCachableTrait = Caching::getAllTraitsUsedByClass($option)
37 37
             ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable");
38 38
 
39
-        if (! $usesCachableTrait) {
39
+        if (!$usesCachableTrait) {
40 40
             $this->error("'{$option}' is not an instance of CachedModel.");
41 41
             $this->line("Only CachedModel instances can be flushed.");
42 42
 
Please login to merge, or discard this patch.
src/Traits/DisableCooldown.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,5 +2,5 @@
 block discarded – undo
2 2
 
3 3
 trait DisableCooldown
4 4
 {
5
-	//
5
+    //
6 6
 }
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/Caching.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $modelClassName = get_class($instance);
99 99
 
100 100
         if( $this->cooldownDisabled($modelClassName) ){
101
-        	return [null, null, null];
101
+            return [null, null, null];
102 102
         }
103 103
 
104 104
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
@@ -179,32 +179,32 @@  discard block
 block discarded – undo
179 179
 
180 180
     public function cooldownDisabled(string $class) : bool
181 181
     {
182
-    	return ! config('laravel-model-caching.enable-cooldown', true)
183
-		    || in_array($class, config('laravel-model-caching.cooldown-disable', []))
184
-		    || $this->getAllTraitsUsedByClass($class)
185
-		            ->contains('GeneaLabs\LaravelModelCaching\Traits\DisableCooldown');
182
+        return ! config('laravel-model-caching.enable-cooldown', true)
183
+            || in_array($class, config('laravel-model-caching.cooldown-disable', []))
184
+            || $this->getAllTraitsUsedByClass($class)
185
+                    ->contains('GeneaLabs\LaravelModelCaching\Traits\DisableCooldown');
186 186
     }
187 187
 
188
-	/** @SuppressWarnings(PHPMD.BooleanArgumentFlag) */
189
-	public static function getAllTraitsUsedByClass(
190
-		string $classname,
191
-		bool $autoload = true
192
-	) : Collection {
193
-		$traits = collect();
188
+    /** @SuppressWarnings(PHPMD.BooleanArgumentFlag) */
189
+    public static function getAllTraitsUsedByClass(
190
+        string $classname,
191
+        bool $autoload = true
192
+    ) : Collection {
193
+        $traits = collect();
194 194
 
195
-		if (class_exists($classname, $autoload)) {
196
-			$traits = collect(class_uses($classname, $autoload));
197
-		}
195
+        if (class_exists($classname, $autoload)) {
196
+            $traits = collect(class_uses($classname, $autoload));
197
+        }
198 198
 
199
-		$parentClass = get_parent_class($classname);
199
+        $parentClass = get_parent_class($classname);
200 200
 
201
-		if ($parentClass) {
202
-			$traits = $traits
203
-				->merge(static::getAllTraitsUsedByClass($parentClass, $autoload));
204
-		}
201
+        if ($parentClass) {
202
+            $traits = $traits
203
+                ->merge(static::getAllTraitsUsedByClass($parentClass, $autoload));
204
+        }
205 205
 
206
-		return $traits;
207
-	}
206
+        return $traits;
207
+    }
208 208
 
209 209
     protected function setCacheCooldownSavedAtTimestamp(Model $instance)
210 210
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
51 51
 
52 52
             $this->cache()
53
-                ->rememberForever($cacheKey, function () {
53
+                ->rememberForever($cacheKey, function() {
54 54
                     return (new Carbon)->now();
55 55
                 });
56 56
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         return "genealabs:laravel-model-caching:"
62 62
             . (config('laravel-model-caching.cache-prefix')
63
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
63
+                ? config('laravel-model-caching.cache-prefix', '').":"
64 64
                 : "");
65 65
     }
66 66
 
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
         $cachePrefix = $this->getCachePrefix();
98 98
         $modelClassName = get_class($instance);
99 99
 
100
-        if( $this->cooldownDisabled($modelClassName) ){
100
+        if ($this->cooldownDisabled($modelClassName)) {
101 101
         	return [null, null, null];
102 102
         }
103 103
 
104 104
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
105 105
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
106 106
 
107
-        if (! $cacheCooldown || $cacheCooldown === 0) {
107
+        if (!$cacheCooldown || $cacheCooldown === 0) {
108 108
             return [null, null, null];
109 109
         }
110 110
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
135 135
 
136
-        if (! $cacheCooldown
136
+        if (!$cacheCooldown
137 137
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
138 138
         ) {
139 139
             return;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     {
159 159
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
160 160
 
161
-        if (! $cacheCooldown) {
161
+        if (!$cacheCooldown) {
162 162
             $instance->flushCache();
163 163
 
164 164
             return;
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
     public function isCachable() : bool
175 175
     {
176 176
         return $this->isCachable
177
-            && ! config('laravel-model-caching.disabled');
177
+            && !config('laravel-model-caching.disabled');
178 178
     }
179 179
 
180 180
     public function cooldownDisabled(string $class) : bool
181 181
     {
182
-    	return ! config('laravel-model-caching.enable-cooldown', true)
182
+    	return !config('laravel-model-caching.enable-cooldown', true)
183 183
 		    || in_array($class, config('laravel-model-caching.cooldown-disable', []))
184 184
 		    || $this->getAllTraitsUsedByClass($class)
185 185
 		            ->contains('GeneaLabs\LaravelModelCaching\Traits\DisableCooldown');
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
214 214
 
215 215
         $instance->cache()
216
-            ->rememberForever($cacheKey, function () {
216
+            ->rememberForever($cacheKey, function() {
217 217
                 return (new Carbon)->now();
218 218
             });
219 219
     }
Please login to merge, or discard this patch.