Passed
Branch master (1227c2)
by Ako
03:34
created
src/drivers/LocalDriver.php 1 patch
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 
47 47
             // Check if given url has been shorten previously
48 48
             $duplicate = Link::where(['long_path' => $this->path])->first();
49
-            if ($duplicate)
50
-                return $duplicate->base_url . "/" . $duplicate->short_path;
49
+            if ($duplicate) {
50
+                            return $duplicate->base_url . "/" . $duplicate->short_path;
51
+            }
51 52
 
52 53
             $short_path = $this->getNextShortpath();
53 54
 
@@ -77,8 +78,9 @@  discard block
 block discarded – undo
77 78
         {
78 79
             $min_length = $this->config['min_length'];
79 80
             $short_path = "";
80
-            for ($i = 0; $i < $min_length; $i++)
81
-                $short_path .= $this->head;
81
+            for ($i = 0; $i < $min_length; $i++) {
82
+                            $short_path .= $this->head;
83
+            }
82 84
             return $short_path;
83 85
         }
84 86
 
@@ -91,8 +93,9 @@  discard block
 block discarded – undo
91 93
          */
92 94
         private function findNextPerm (string $current_perm) :string
93 95
 		{
94
-			if (!strlen($current_perm))
95
-			    return $this->head;
96
+			if (!strlen($current_perm)) {
97
+						    return $this->head;
98
+			}
96 99
 
97 100
 			$arr = array_reverse(str_split($current_perm));
98 101
 			foreach($arr as $key => $current_char) {
@@ -120,12 +123,15 @@  discard block
 block discarded – undo
120 123
         {
121 124
             $parse = parse_url($url);
122 125
             $path = "";
123
-            if ($parse['path'] ?? null)
124
-                $path .= str::replaceFirst("/", "", $parse['path']);
125
-            if ($parse['query'] ?? null)
126
-                $path .= "?" . $parse['query'];
127
-            if ($parse['fragment'] ?? null)
128
-                $path .= "#" . $parse['fragment'];
126
+            if ($parse['path'] ?? null) {
127
+                            $path .= str::replaceFirst("/", "", $parse['path']);
128
+            }
129
+            if ($parse['query'] ?? null) {
130
+                            $path .= "?" . $parse['query'];
131
+            }
132
+            if ($parse['fragment'] ?? null) {
133
+                            $path .= "#" . $parse['fragment'];
134
+            }
129 135
 
130 136
             $this->base_url = str_replace("/" . $path, "", $url);
131 137
             $this->path = $path;
@@ -151,18 +157,22 @@  discard block
 block discarded – undo
151 157
             // so we must find the latest one(short_path) in the permutation of the main_str
152 158
             $latest = collect(\DB::select("SELECT short_path FROM $tbl WHERE created_at = (SELECT MAX(created_at) FROM $tbl)"));
153 159
 
154
-            if (!$latest->count()) return $this->getFirstUrl();
160
+            if (!$latest->count()) {
161
+            	return $this->getFirstUrl();
162
+            }
155 163
 
156
-            if ($latest->count() == 1)
157
-                return $this->findNextPerm($latest->first()->short_path);
164
+            if ($latest->count() == 1) {
165
+                            return $this->findNextPerm($latest->first()->short_path);
166
+            }
158 167
 
159 168
             foreach ($latest->reverse() as $key => $item) {
160 169
                 $next = $this->findNextPerm($item->short_path);
161 170
 
162 171
                 // If next permutation of current item is in fetched items
163 172
                 // find next permutation of the next fetched one
164
-                if (!$latest->contains("short_path", $next))
165
-                    return $next;
173
+                if (!$latest->contains("short_path", $next)) {
174
+                                    return $next;
175
+                }
166 176
             }
167 177
         }
168 178
 	}
169 179
\ No newline at end of file
Please login to merge, or discard this patch.
src/Shorturl.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@
 block discarded – undo
53 53
 		
54 54
 		private function getDriverInstance ()
55 55
 		{
56
-			if (!$this->driver_instance)
57
-				$this->setDriverInstance();
56
+			if (!$this->driver_instance) {
57
+							$this->setDriverInstance();
58
+			}
58 59
 			
59 60
 			return $this->driver_instance;
60 61
 		}
Please login to merge, or discard this patch.