@@ -104,7 +104,6 @@ |
||
| 104 | 104 | * |
| 105 | 105 | * @author Alireza Josheghani <[email protected]> |
| 106 | 106 | * @since 27 Oct , 2016 |
| 107 | - * @param \Illuminate\Http\Request $request |
|
| 108 | 107 | * @return boolean |
| 109 | 108 | */ |
| 110 | 109 | public function isHttpie() |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var array |
| 28 | 28 | **/ |
| 29 | - protected $except = []; |
|
| 29 | + protected $except = [ ]; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Bots list |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $this->agent = $request->header('user-agent'); |
| 49 | 49 | |
| 50 | - if(function_exists('config_path')){ |
|
| 50 | + if (function_exists('config_path')) { |
|
| 51 | 51 | |
| 52 | 52 | // if exists bots file then include list |
| 53 | - if(file_exists(config_path('bots.php'))) { |
|
| 53 | + if (file_exists(config_path('bots.php'))) { |
|
| 54 | 54 | |
| 55 | 55 | // require bots list |
| 56 | 56 | $this->bots = require config_path('bots.php'); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $agent = new Agent; |
| 72 | 72 | |
| 73 | 73 | $agent->setUserAgent($this->agent); |
| 74 | - if(! $agent->browser() |
|
| 74 | + if ( ! $agent->browser() |
|
| 75 | 75 | || ! $agent->device() |
| 76 | 76 | || ! $agent->platform($this->agent) |
| 77 | 77 | || ! $agent->version($agent->browser()) |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function isCurl() |
| 94 | 94 | { |
| 95 | - if(preg_match('/curl/', $this->agent)) { |
|
| 95 | + if (preg_match('/curl/', $this->agent)) { |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function isHttpie() |
| 111 | 111 | { |
| 112 | - if(preg_match('/HTTPie/', $this->agent)) { |
|
| 112 | + if (preg_match('/HTTPie/', $this->agent)) { |
|
| 113 | 113 | return true; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function isRobot() |
| 126 | 126 | { |
| 127 | - foreach ($this->bots as $bot){ |
|
| 128 | - if(preg_match('/' . $bot . '/', $this->agent)) { |
|
| 127 | + foreach ($this->bots as $bot) { |
|
| 128 | + if (preg_match('/' . $bot . '/', $this->agent)) { |
|
| 129 | 129 | return true; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function checkExcept($method) |
| 145 | 145 | { |
| 146 | - if(!empty($this->except)) { |
|
| 147 | - foreach ($this->except as $except){ |
|
| 148 | - if($except === $method) { |
|
| 146 | + if ( ! empty($this->except)) { |
|
| 147 | + foreach ($this->except as $except) { |
|
| 148 | + if ($except === $method) { |
|
| 149 | 149 | return true; |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $methods = get_class_methods($this); |
| 168 | 168 | |
| 169 | - foreach ($methods as $key => $method){ |
|
| 170 | - if(substr($method, 0, 2) !== 'is' || $this->checkExcept($method)) { |
|
| 171 | - unset($methods[$key]); |
|
| 169 | + foreach ($methods as $key => $method) { |
|
| 170 | + if (substr($method, 0, 2) !== 'is' || $this->checkExcept($method)) { |
|
| 171 | + unset($methods[ $key ]); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -16,8 +16,8 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function handle(Request $request, Closure $next) |
| 18 | 18 | { |
| 19 | - foreach ($this->methods() as $method){ |
|
| 20 | - if($this->$method() === true) { |
|
| 19 | + foreach ($this->methods() as $method) { |
|
| 20 | + if ($this->$method() === true) { |
|
| 21 | 21 | return abort(403, 'Unauthorized action !'); |
| 22 | 22 | } |
| 23 | 23 | } |