@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @param callable $callback |
9 | 9 | */ |
10 | - protected function checkParamsViaAvailability($data,callable $callback) |
|
10 | + protected function checkParamsViaAvailability($data, callable $callback) |
|
11 | 11 | { |
12 | 12 | // if an authenticate is provided via the existing check method, |
13 | 13 | // then we return the value of the data that we are checking for with callback help. |
14 | - if($this->check() && isset($this->params[$data])){ |
|
15 | - return call_user_func_array($callback,[$this->params[$data]]); |
|
14 | + if ($this->check() && isset($this->params[$data])) { |
|
15 | + return call_user_func_array($callback, [$this->params[$data]]); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | return null; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | // we will determine whether |
29 | 29 | // the http path is correct for this method. |
30 | - if(isset($getHttp[$type]) and $getHttp[$type]!==httpMethod()){ |
|
30 | + if (isset($getHttp[$type]) and $getHttp[$type]!==httpMethod()) { |
|
31 | 31 | $this->getExceptionForHttp($getHttp[$type]); |
32 | 32 | } |
33 | 33 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | { |
40 | 40 | // if there is a token in the headers, |
41 | 41 | // we return the callback. |
42 | - if(!is_null($this->getTokenSentByUser())){ |
|
43 | - return call_user_func_array($callback,[$this->getTokenSentByUser()]); |
|
42 | + if (!is_null($this->getTokenSentByUser())) { |
|
43 | + return call_user_func_array($callback, [$this->getTokenSentByUser()]); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | //token false |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | // with query we bind the returned values to the params property of the auth object. |
43 | 43 | // and so the auth object will make a final return with these values. |
44 | - $this->paramValues('check',$query); |
|
44 | + $this->paramValues('check', $query); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | // with query we bind the returned values to the params property of the auth object. |
60 | 60 | // and so the auth object will make a final return with these values. |
61 | - $this->paramValues('login',$query); |
|
61 | + $this->paramValues('login', $query); |
|
62 | 62 | |
63 | 63 | // we assign the credential hash value |
64 | 64 | // to the global of the authenticate object. |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | // we update the token value. |
69 | 69 | $this->updateToken(); |
70 | 70 | |
71 | - if(isset($this->auth->params['authToken'])){ |
|
71 | + if (isset($this->auth->params['authToken'])) { |
|
72 | 72 | $this->saveDeviceToken(); |
73 | 73 | } |
74 | 74 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | |
87 | 87 | // with query we bind the returned values to the params property of the auth object. |
88 | 88 | // and so the auth object will make a final return with these values. |
89 | - $this->paramValues('logout',$query); |
|
89 | + $this->paramValues('logout', $query); |
|
90 | 90 | |
91 | 91 | //token updating as null |
92 | - if(isset($this->auth->params['authToken'])){ |
|
92 | + if (isset($this->auth->params['authToken'])) { |
|
93 | 93 | $this->deleteDeviceToken(); |
94 | 94 | } |
95 | 95 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | protected function callbackQueryWithoutCredentials($driver) |
32 | 32 | { |
33 | - if($this->isCallableAddToWhere()){ |
|
33 | + if ($this->isCallableAddToWhere()) { |
|
34 | 34 | |
35 | 35 | return $driver::where(function($query) { |
36 | 36 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | return DeviceToken::where(function($query) use($token) { |
53 | 53 | |
54 | 54 | //where query for token |
55 | - $query->where('token_integer',crc32(md5($token))); |
|
56 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
55 | + $query->where('token_integer', crc32(md5($token))); |
|
56 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
57 | 57 | |
58 | 58 | // if the addToWhereClosure value is a closure, |
59 | 59 | // then in this case we actually run |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | return DeviceToken::where(function($query) use($token) { |
83 | 83 | |
84 | 84 | //where query for token |
85 | - $query->where('token_integer',crc32(md5($token))); |
|
86 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
85 | + $query->where('token_integer', crc32(md5($token))); |
|
86 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
87 | 87 | |
88 | 88 | // if the addToWhereClosure value is a closure, |
89 | 89 | // then in this case we actually run |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * @param array $credentials |
101 | 101 | * @return mixed |
102 | 102 | */ |
103 | - protected function queryAddToWhere($query,$credentials=array()) |
|
103 | + protected function queryAddToWhere($query, $credentials = array()) |
|
104 | 104 | { |
105 | 105 | // if the addToWhereClosure value is a closure, |
106 | 106 | // then in this case we actually run |
107 | 107 | // the closure object and add it to the query value. |
108 | - if($this->isCallableAddToWhere()){ |
|
109 | - return $this->query['addToWhere']($query,$credentials); |
|
108 | + if ($this->isCallableAddToWhere()) { |
|
109 | + return $this->query['addToWhere']($query, $credentials); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | //we get the model specified for the builder. |
122 | 122 | $driver = $this->query['driver']; |
123 | 123 | |
124 | - if(count($credentials->get())==0){ |
|
124 | + if (count($credentials->get())==0) { |
|
125 | 125 | |
126 | 126 | // if the credential array is empty in the config section, |
127 | 127 | // then you must run the query with a callable value of addToWhere value. |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | // |
132 | - if($this->isCallableAddToWhere()){ |
|
133 | - return $this->queryAddToWhere($driver,$credentials->get()); |
|
132 | + if ($this->isCallableAddToWhere()) { |
|
133 | + return $this->queryAddToWhere($driver, $credentials->get()); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // using the driver object we write the query builder statement. |
@@ -139,24 +139,24 @@ discard block |
||
139 | 139 | |
140 | 140 | // with the callback method (eloquent model) |
141 | 141 | // we write the where clause. |
142 | - foreach ($credentials->get() as $credential=>$credentialValue){ |
|
143 | - $query->where($credential,$credentialValue); |
|
142 | + foreach ($credentials->get() as $credential=>$credentialValue) { |
|
143 | + $query->where($credential, $credentialValue); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // if the addToWhereClosure value is a closure, |
147 | 147 | // then in this case we actually run |
148 | 148 | // the closure object and add it to the query value. |
149 | - $this->queryAddToWhere($query,$credentials->get(),$credentials->get()); |
|
149 | + $this->queryAddToWhere($query, $credentials->get(), $credentials->get()); |
|
150 | 150 | }); |
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @return void|mixed |
155 | 155 | */ |
156 | - protected function updateToken($token=null) |
|
156 | + protected function updateToken($token = null) |
|
157 | 157 | { |
158 | 158 | //if query status value is true |
159 | - if($this->auth->params['status']){ |
|
159 | + if ($this->auth->params['status']) { |
|
160 | 160 | |
161 | 161 | // we go to the method that produces |
162 | 162 | // the classical token value and get the token value. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // if there is no update, we reset the status value to 0. |
167 | 167 | $update = $this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
168 | 168 | |
169 | - if(!$update){ |
|
169 | + if (!$update) { |
|
170 | 170 | $this->auth->params['status'] = 0; |
171 | 171 | $this->auth->params['exception'] = 'update'; |
172 | 172 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | { |
183 | 183 | $token_integer = crc32(md5($this->auth->params['token'])); |
184 | 184 | |
185 | - if(!is_null($token_integer)){ |
|
185 | + if (!is_null($token_integer)) { |
|
186 | 186 | |
187 | - if(DeviceToken::where('user_id',$this->auth->params['authId']) |
|
188 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0){ |
|
187 | + if (DeviceToken::where('user_id', $this->auth->params['authId']) |
|
188 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0) { |
|
189 | 189 | return DeviceToken::create([ |
190 | 190 | 'user_id' => $this->auth->params['authId'], |
191 | 191 | 'token' => $this->auth->params['token'], |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | 'expire' => 0 |
196 | 196 | ]); |
197 | 197 | } |
198 | - else{ |
|
198 | + else { |
|
199 | 199 | |
200 | - return DeviceToken::where('user_id',$this->auth->params['authId']) |
|
201 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
200 | + return DeviceToken::where('user_id', $this->auth->params['authId']) |
|
201 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
202 | 202 | ->update([ |
203 | 203 | 'token' => $this->auth->params['token'], |
204 | 204 | 'token_integer' => $token_integer |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | { |
219 | 219 | $token_integer = crc32(md5($this->auth->getTokenData())); |
220 | 220 | |
221 | - if(!is_null($token_integer)){ |
|
221 | + if (!is_null($token_integer)) { |
|
222 | 222 | |
223 | - if(DeviceToken::where('user_id',$this->auth->params['authId']) |
|
224 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()){ |
|
223 | + if (DeviceToken::where('user_id', $this->auth->params['authId']) |
|
224 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()) { |
|
225 | 225 | |
226 | - DeviceToken::where('token_integer',$token_integer)->delete(); |
|
226 | + DeviceToken::where('token_integer', $token_integer)->delete(); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 |