@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | protected $props = []; |
10 | 10 | protected $config, $main_str, $head, $tail, $base_url, $path; |
11 | 11 | |
12 | - public function __construct () |
|
12 | + public function __construct() |
|
13 | 13 | { |
14 | 14 | $this->config = config('shorturl.drivers.local'); |
15 | 15 | $this->main_str = $this->config['str_shuffled']; |
16 | 16 | $this->head = $this->main_str[0]; |
17 | 17 | $this->tail = $this->main_str[strlen($this->main_str) - 1]; |
18 | - $this->checkCaseSensitive (); |
|
18 | + $this->checkCaseSensitive(); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - public function expand (string $url) :string |
|
26 | + public function expand(string $url) :string |
|
27 | 27 | { |
28 | 28 | $this->parseUrl($url); |
29 | 29 | $link = Link::where("short_path", $this->path)->first(); |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * @return string |
41 | 41 | * @throws \Exception |
42 | 42 | */ |
43 | - public function shorten (string $url) :string |
|
43 | + public function shorten(string $url) :string |
|
44 | 44 | { |
45 | - $this->parseUrl ($url); |
|
45 | + $this->parseUrl($url); |
|
46 | 46 | |
47 | 47 | // Check if given url has been shorten previously |
48 | 48 | $duplicate = Link::where(['long_path' => $this->path])->first(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - private function getFirstUrl () : string |
|
76 | + private function getFirstUrl() : string |
|
77 | 77 | { |
78 | 78 | $min_length = $this->config['min_length']; |
79 | 79 | $short_path = ""; |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * @param string $current_perm |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - private function findNextPerm (string $current_perm) :string |
|
92 | + private function findNextPerm(string $current_perm) :string |
|
93 | 93 | { |
94 | 94 | if (!strlen($current_perm)) |
95 | 95 | return $this->head; |
96 | 96 | |
97 | 97 | $arr = array_reverse(str_split($current_perm)); |
98 | - foreach($arr as $key => $current_char) { |
|
98 | + foreach ($arr as $key => $current_char) { |
|
99 | 99 | if ($current_char == $this->tail) { |
100 | 100 | $current_perm = Str::replaceLast($current_char, "", $current_perm); |
101 | 101 | return $this->findNextPerm($current_perm) . $this->head; |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return LocalDriver |
112 | 112 | */ |
113 | - public function withProperties (array $props = []) :LocalDriver |
|
113 | + public function withProperties(array $props = []) :LocalDriver |
|
114 | 114 | { |
115 | 115 | $this->props = array_merge($this->props, $props); |
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - private function parseUrl (string $url) |
|
119 | + private function parseUrl(string $url) |
|
120 | 120 | { |
121 | 121 | $parse = parse_url($url); |
122 | 122 | $path = ""; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $this->path = $path; |
132 | 132 | } |
133 | 133 | |
134 | - private function checkCaseSensitive () |
|
134 | + private function checkCaseSensitive() |
|
135 | 135 | { |
136 | 136 | if ((!$this->config['case_sensitive'] ?? null)) { |
137 | 137 | // Remove upper cases from main string |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - private function getNextShortpath () : string |
|
145 | + private function getNextShortpath() : string |
|
146 | 146 | { |
147 | 147 | $tbl = (new Link)->getTable(); |
148 | 148 | // Get latest short_path(s) |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | protected $driver; |
11 | 11 | private $driver_instance; |
12 | 12 | |
13 | - public function __construct (DriverFactory $factory) |
|
13 | + public function __construct(DriverFactory $factory) |
|
14 | 14 | { |
15 | 15 | $this->factory = $factory; |
16 | 16 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return Shorturl |
22 | 22 | */ |
23 | - public function onDriver (string $driver) |
|
23 | + public function onDriver(string $driver) |
|
24 | 24 | { |
25 | 25 | $this->driver = $driver; |
26 | 26 | $this->setDriverInstance(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return void |
32 | 32 | */ |
33 | - private function setDriverInstance () |
|
33 | + private function setDriverInstance() |
|
34 | 34 | { |
35 | 35 | $this->driver_instance = $this->factory->make($this->getDriver()); |
36 | 36 | } |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function getDriver (): string |
|
44 | + public function getDriver(): string |
|
45 | 45 | { |
46 | 46 | return $this->driver ?: config("shorturl.drivers.default"); |
47 | 47 | } |
48 | 48 | |
49 | - public function __call ($method, $args) |
|
49 | + public function __call($method, $args) |
|
50 | 50 | { |
51 | - return call_user_func_array(array ($this->getDriverInstance(), $method), $args); |
|
51 | + return call_user_func_array(array($this->getDriverInstance(), $method), $args); |
|
52 | 52 | } |
53 | 53 | |
54 | - private function getDriverInstance () |
|
54 | + private function getDriverInstance() |
|
55 | 55 | { |
56 | 56 | if (!$this->driver_instance) |
57 | 57 | $this->setDriverInstance(); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * |
11 | 11 | * @return LocalDriver |
12 | 12 | */ |
13 | - public function make (string $driver) |
|
13 | + public function make(string $driver) |
|
14 | 14 | { |
15 | 15 | switch ($driver) { |
16 | 16 | case "local": |