@@ -55,7 +55,7 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | private function getComposerPackages() |
| 57 | 57 | { |
| 58 | - if (! file_exists('composer.lock')) { |
|
| 58 | + if (!file_exists('composer.lock')) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * |
| 203 | - * @param Model\UserAgent $device |
|
| 203 | + * @param Model\Device $device |
|
| 204 | 204 | * @param DeviceDetector $dd |
| 205 | 205 | */ |
| 206 | 206 | private function hydrateDevice(Model\Device $device, DeviceDetector $dd) |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * an empty UserAgent makes no sense |
| 98 | 98 | */ |
| 99 | 99 | if ($userAgent == '') { |
| 100 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 100 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $params = [ |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | * no json returned? |
| 118 | 118 | */ |
| 119 | 119 | $contentType = $response->getHeader('Content-Type'); |
| 120 | - if (! isset($contentType[0]) || $contentType[0] != 'application/json') { |
|
| 121 | - throw new Exception\RequestException('Could not get valid "application/json" response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 120 | + if (!isset($contentType[0]) || $contentType[0] != 'application/json') { |
|
| 121 | + throw new Exception\RequestException('Could not get valid "application/json" response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $content = json_decode($response->getBody()->getContents()); |
@@ -127,29 +127,29 @@ discard block |
||
| 127 | 127 | * No result found? |
| 128 | 128 | */ |
| 129 | 129 | if (isset($content->flag) && $content->flag == 3) { |
| 130 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 130 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /* |
| 134 | 134 | * Errors |
| 135 | 135 | */ |
| 136 | 136 | if (isset($content->flag) && $content->flag == 4) { |
| 137 | - throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName()); |
|
| 137 | + throw new Exception\InvalidCredentialsException('Your API key "'.$this->apiKey.'" is not valid for '.$this->getName()); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | if (isset($content->flag) && $content->flag == 6) { |
| 141 | - throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API key "' . $this->apiKey . '" for ' . $this->getName()); |
|
| 141 | + throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API key "'.$this->apiKey.'" for '.$this->getName()); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if (isset($content->flag) && $content->flag > 3) { |
| 145 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 145 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /* |
| 149 | 149 | * Missing data? |
| 150 | 150 | */ |
| 151 | - if (! $content instanceof stdClass || ! isset($content->info)) { |
|
| 152 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 151 | + if (!$content instanceof stdClass || !isset($content->info)) { |
|
| 152 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return $content; |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * |
| 203 | - * @param Model\UserAgent $device |
|
| 203 | + * @param Model\Device $device |
|
| 204 | 204 | * @param DeviceDetector $dd |
| 205 | 205 | */ |
| 206 | 206 | private function hydrateDevice(Model\Device $device, DeviceDetector $dd) |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | * an empty UserAgent makes no sense |
| 92 | 92 | */ |
| 93 | 93 | if ($userAgent == '') { |
| 94 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 94 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $parameters = '/' . $this->apiKey; |
|
| 98 | - $parameters .= '/' . rawurlencode($userAgent); |
|
| 97 | + $parameters = '/'.$this->apiKey; |
|
| 98 | + $parameters .= '/'.rawurlencode($userAgent); |
|
| 99 | 99 | |
| 100 | - $uri = self::$uri . $parameters; |
|
| 100 | + $uri = self::$uri.$parameters; |
|
| 101 | 101 | |
| 102 | 102 | $request = new Request('GET', $uri); |
| 103 | 103 | |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * Error |
| 118 | 118 | */ |
| 119 | 119 | if (isset($content->error->code) && $content->error->code == 'key_invalid') { |
| 120 | - throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName(), null, $ex); |
|
| 120 | + throw new Exception\InvalidCredentialsException('Your API key "'.$this->apiKey.'" is not valid for '.$this->getName(), null, $ex); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if (isset($content->error->code) && $content->error->code == 'useragent_invalid') { |
| 124 | - throw new Exception\RequestException('User agent is invalid "' . $userAgent . '"'); |
|
| 124 | + throw new Exception\RequestException('User agent is invalid "'.$userAgent.'"'); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * no json returned? |
| 133 | 133 | */ |
| 134 | 134 | $contentType = $response->getHeader('Content-Type'); |
| 135 | - if (! isset($contentType[0]) || $contentType[0] != 'application/json') { |
|
| 136 | - throw new Exception\RequestException('Could not get valid "application/json" response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 135 | + if (!isset($contentType[0]) || $contentType[0] != 'application/json') { |
|
| 136 | + throw new Exception\RequestException('Could not get valid "application/json" response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $content = json_decode($response->getBody()->getContents()); |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | * No result |
| 143 | 143 | */ |
| 144 | 144 | if (isset($content->error->code) && $content->error->code == 'useragent_not_found') { |
| 145 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 145 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /* |
| 149 | 149 | * Missing data? |
| 150 | 150 | */ |
| 151 | - if (! $content instanceof stdClass || ! isset($content->data)) { |
|
| 152 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Data is missing "' . $response->getBody()->getContents() . '"'); |
|
| 151 | + if (!$content instanceof stdClass || !isset($content->data)) { |
|
| 152 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Data is missing "'.$response->getBody()->getContents().'"'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return $content->data; |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * |
| 203 | - * @param Model\UserAgent $device |
|
| 203 | + * @param Model\Device $device |
|
| 204 | 204 | * @param DeviceDetector $dd |
| 205 | 205 | */ |
| 206 | 206 | private function hydrateDevice(Model\Device $device, DeviceDetector $dd) |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * an empty UserAgent makes no sense |
| 124 | 124 | */ |
| 125 | 125 | if ($userAgent == '') { |
| 126 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 126 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $params = [ |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * no json returned? |
| 142 | 142 | */ |
| 143 | 143 | $contentType = $response->getHeader('Content-Type'); |
| 144 | - if (! isset($contentType[0]) || $contentType[0] != 'application/json') { |
|
| 145 | - throw new Exception\RequestException('Could not get valid "application/json" response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 144 | + if (!isset($contentType[0]) || $contentType[0] != 'application/json') { |
|
| 145 | + throw new Exception\RequestException('Could not get valid "application/json" response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $content = json_decode($response->getBody()->getContents()); |
@@ -151,36 +151,36 @@ discard block |
||
| 151 | 151 | * No result |
| 152 | 152 | */ |
| 153 | 153 | if (isset($content->message_code) && $content->message_code == 'no_user_agent') { |
| 154 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 154 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /* |
| 158 | 158 | * Limit exceeded |
| 159 | 159 | */ |
| 160 | 160 | if (isset($content->message_code) && $content->message_code == 'usage_limit_exceeded') { |
| 161 | - throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API key "' . $this->apiKey . '" for ' . $this->getName()); |
|
| 161 | + throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API key "'.$this->apiKey.'" for '.$this->getName()); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /* |
| 165 | 165 | * Error |
| 166 | 166 | */ |
| 167 | 167 | if (isset($content->message_code) && $content->message_code == 'no_api_user_key') { |
| 168 | - throw new Exception\InvalidCredentialsException('Missing API key for ' . $this->getName()); |
|
| 168 | + throw new Exception\InvalidCredentialsException('Missing API key for '.$this->getName()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | if (isset($content->message_code) && $content->message_code == 'user_key_invalid') { |
| 172 | - throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName()); |
|
| 172 | + throw new Exception\InvalidCredentialsException('Your API key "'.$this->apiKey.'" is not valid for '.$this->getName()); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if (! isset($content->result) || $content->result !== 'success') { |
|
| 176 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 175 | + if (!isset($content->result) || $content->result !== 'success') { |
|
| 176 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /* |
| 180 | 180 | * Missing data? |
| 181 | 181 | */ |
| 182 | - if (! $content instanceof stdClass || ! isset($content->parse) || ! $content->parse instanceof stdClass) { |
|
| 183 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . print_r($content, true) . '"'); |
|
| 182 | + if (!$content instanceof stdClass || !isset($content->parse) || !$content->parse instanceof stdClass) { |
|
| 183 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Response is "'.print_r($content, true).'"'); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | return $content->parse; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * No result found? |
| 290 | 290 | */ |
| 291 | 291 | if ($this->hasResult($resultRaw) !== true) { |
| 292 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 292 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /* |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function __construct() |
| 84 | 84 | { |
| 85 | - if (! file_exists('vendor/' . $this->getPackageName() . '/composer.json')) { |
|
| 86 | - throw new PackageNotLoadedException('You need to install the package ' . $this->getPackageName() . ' to use this provider'); |
|
| 85 | + if (!file_exists('vendor/'.$this->getPackageName().'/composer.json')) { |
|
| 86 | + throw new PackageNotLoadedException('You need to install the package '.$this->getPackageName().' to use this provider'); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * No result found? |
| 214 | 214 | */ |
| 215 | 215 | if ($parser->isDetected() !== true) { |
| 216 | - throw new NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 216 | + throw new NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /* |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | public function getVersion() |
| 122 | 122 | { |
| 123 | - $version = $this->getParser()->getWurflInfo()->version; |
|
| 123 | + $version = $this->getParser()->getWurflInfo()->version; |
|
| 124 | 124 | |
| 125 | 125 | preg_match("/\d+(?:\.\d+)+/", $version, $result); |
| 126 | 126 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * No result found? |
| 236 | 236 | */ |
| 237 | 237 | if ($this->hasResult($deviceRaw) !== true) { |
| 238 | - throw new NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 238 | + throw new NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /* |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function __construct(Parser $parser = null) |
| 117 | 117 | { |
| 118 | - if ($parser === null && ! file_exists('vendor/' . $this->getPackageName() . '/composer.json')) { |
|
| 119 | - throw new PackageNotLoadedException('You need to install the package ' . $this->getPackageName() . ' to use this provider'); |
|
| 118 | + if ($parser === null && !file_exists('vendor/'.$this->getPackageName().'/composer.json')) { |
|
| 119 | + throw new PackageNotLoadedException('You need to install the package '.$this->getPackageName().' to use this provider'); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $this->parser = $parser; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * No result found? |
| 269 | 269 | */ |
| 270 | 270 | if ($this->hasResult($resultRaw) !== true) { |
| 271 | - throw new NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 271 | + throw new NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /* |
@@ -52,11 +52,11 @@ |
||
| 52 | 52 | /* @var $response \GuzzleHttp\Psr7\Response */ |
| 53 | 53 | $response = $this->getClient()->send($request); |
| 54 | 54 | } catch (GuzzleHttpException $ex) { |
| 55 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '"', null, $ex); |
|
| 55 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'"', null, $ex); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if ($response->getStatusCode() !== 200) { |
| 59 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Status code is: "' . $response->getStatusCode() . '"'); |
|
| 59 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Status code is: "'.$response->getStatusCode().'"'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $response; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * an empty UserAgent makes no sense |
| 120 | 120 | */ |
| 121 | 121 | if ($userAgent == '') { |
| 122 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 122 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $params = [ |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $prevEx = $ex->getPrevious(); |
| 145 | 145 | |
| 146 | 146 | if ($prevEx->hasResponse() === true && $prevEx->getResponse()->getStatusCode() === 403) { |
| 147 | - throw new Exception\InvalidCredentialsException('Your API userId "' . $this->apiUserId . '" and key "' . $this->apiKey . '" is not valid for ' . $this->getName(), null, $ex); |
|
| 147 | + throw new Exception\InvalidCredentialsException('Your API userId "'.$this->apiUserId.'" and key "'.$this->apiKey.'" is not valid for '.$this->getName(), null, $ex); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | throw $ex; |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | * no json returned? |
| 155 | 155 | */ |
| 156 | 156 | $contentType = $response->getHeader('Content-Type'); |
| 157 | - if (! isset($contentType[0]) || $contentType[0] != 'application/json;charset=UTF-8') { |
|
| 158 | - throw new Exception\RequestException('Could not get valid "application/json" response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 157 | + if (!isset($contentType[0]) || $contentType[0] != 'application/json;charset=UTF-8') { |
|
| 158 | + throw new Exception\RequestException('Could not get valid "application/json" response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $content = json_decode($response->getBody()->getContents()); |
@@ -167,15 +167,15 @@ discard block |
||
| 167 | 167 | switch ($content->api_error) { |
| 168 | 168 | |
| 169 | 169 | case 1: |
| 170 | - throw new Exception\RequestException('"' . $content->api_error_msg . '" response from "' . $request->getUri() . '". Response is "' . print_r($content, true) . '"'); |
|
| 170 | + throw new Exception\RequestException('"'.$content->api_error_msg.'" response from "'.$request->getUri().'". Response is "'.print_r($content, true).'"'); |
|
| 171 | 171 | break; |
| 172 | 172 | |
| 173 | 173 | case 2: |
| 174 | - throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API userId "' . $this->apiUserId . '" and key "' . $this->apiKey . '" for ' . $this->getName()); |
|
| 174 | + throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API userId "'.$this->apiUserId.'" and key "'.$this->apiKey.'" for '.$this->getName()); |
|
| 175 | 175 | break; |
| 176 | 176 | |
| 177 | 177 | default: |
| 178 | - throw new Exception\RequestException('"' . $content->api_error_msg . '" response from "' . $request->getUri() . '". Response is "' . print_r($content, true) . '"'); |
|
| 178 | + throw new Exception\RequestException('"'.$content->api_error_msg.'" response from "'.$request->getUri().'". Response is "'.print_r($content, true).'"'); |
|
| 179 | 179 | break; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | /* |
| 184 | 184 | * Missing data? |
| 185 | 185 | */ |
| 186 | - if (! $content instanceof stdClass) { |
|
| 187 | - throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"'); |
|
| 186 | + if (!$content instanceof stdClass) { |
|
| 187 | + throw new Exception\RequestException('Could not get valid response from "'.$request->getUri().'". Response is "'.$response->getBody()->getContents().'"'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | return $content; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * No result found? |
| 298 | 298 | */ |
| 299 | 299 | if ($this->hasResult($resultRaw) !== true) { |
| 300 | - throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 300 | + throw new Exception\NoResultFoundException('No result found for user agent: '.$userAgent); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /* |