@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | $pattern = preg_replace('|(/)\\d+(/?)|u', '$1{id}$2', $pattern); |
| 46 | 46 | |
| 47 | 47 | // Make regex |
| 48 | - $pattern = '|^/' . $pattern . '$|ui'; |
|
| 48 | + $pattern = '|^/'.$pattern.'$|ui'; |
|
| 49 | 49 | |
| 50 | 50 | // Search the map for the uri that matches |
| 51 | 51 | return ($uri = $this->maps[$version]->search( |
| 52 | - function ($model, $uri) use ($pattern) { |
|
| 52 | + function($model, $uri) use ($pattern) { |
|
| 53 | 53 | return preg_match($pattern, $uri); |
| 54 | 54 | } |
| 55 | 55 | )) ? $this->maps[$version][$uri] : null; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | if (!array_key_exists($version, $this->maps)) { |
| 66 | 66 | $this->maps[$version] = collect( |
| 67 | 67 | json_decode( |
| 68 | - @file_get_contents(__DIR__ . '/../Models/v' . str_replace('.', '_', $version) . '/map.json'), |
|
| 68 | + @file_get_contents(__DIR__.'/../Models/v'.str_replace('.', '_', $version).'/map.json'), |
|
| 69 | 69 | true |
| 70 | 70 | ) |
| 71 | 71 | ); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected function endpoint() |
| 60 | 60 | { |
| 61 | - return 'system/members/' . $this->member_id . '/tokens'; |
|
| 61 | + return 'system/members/'.$this->member_id.'/tokens'; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getUsername() |
| 120 | 120 | { |
| 121 | - return $this->company_id . '+' . $this->username; |
|
| 121 | + return $this->company_id.'+'.$this->username; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $this->app->singleton( |
| 80 | 80 | Client::class, |
| 81 | - function (Application $app) { |
|
| 81 | + function(Application $app) { |
|
| 82 | 82 | return (new Client( |
| 83 | 83 | $app->make(Token::class), |
| 84 | 84 | $app->make(Guzzle::class), |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $this->app->singleton( |
| 117 | 117 | Token::class, |
| 118 | - function (Application $app) { |
|
| 118 | + function(Application $app) { |
|
| 119 | 119 | return (new Token())->setCompanyId($app->config->get('services.connectwise.company_id')) |
| 120 | 120 | ->setMemberId($this->determineMemberId()); |
| 121 | 121 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use Illuminate\Support\Collection; |
| 4 | 4 | |
| 5 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 5 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | class Swagger |
| 8 | 8 | { |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | // Make array of types keyed by property |
| 69 | 69 | $property_type = collect($attributes['properties']) |
| 70 | - ->map(function ($attributes) { |
|
| 70 | + ->map(function($attributes) { |
|
| 71 | 71 | return $this->parseType($attributes); |
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | - $casts = $property_type->map(function ($type, $property) { |
|
| 74 | + $casts = $property_type->map(function($type, $property) { |
|
| 75 | 75 | $primitives = [ |
| 76 | 76 | 'array', |
| 77 | 77 | 'boolean', |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | 'string', |
| 82 | 82 | ]; |
| 83 | 83 | |
| 84 | - return " '${property}' => " . ((in_array($type, $primitives)) ? "'${type}'" : "${type}::class"); |
|
| 84 | + return " '${property}' => ".((in_array($type, $primitives)) ? "'${type}'" : "${type}::class"); |
|
| 85 | 85 | }) |
| 86 | 86 | ->values() |
| 87 | 87 | ->sort() |
| 88 | 88 | ->implode(",\n"); |
| 89 | 89 | |
| 90 | - $properties = $property_type->map(function ($type, $property) { |
|
| 90 | + $properties = $property_type->map(function($type, $property) { |
|
| 91 | 91 | return " * @property ${type} $${property}"; |
| 92 | 92 | }) |
| 93 | 93 | ->values() |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $model = preg_replace('|{{ Namespace }}|u', $this->getNamespace(), $template); |
| 98 | 98 | $model = preg_replace('|{{ Version }}|u', $this->version, $model); |
| 99 | 99 | $model = preg_replace('|{{ Class }}|u', $class, $model); |
| 100 | - $model = preg_replace('|{{ Description }}|u', $attributes['description'] ?? 'Model for ' . $class, $model); |
|
| 100 | + $model = preg_replace('|{{ Description }}|u', $attributes['description'] ?? 'Model for '.$class, $model); |
|
| 101 | 101 | $model = preg_replace('|{{ Casts }}|u', $casts, $model); |
| 102 | 102 | $model = preg_replace('|{{ Properties }}|u', $properties, $model); |
| 103 | 103 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | $this->swaggers = collect([]); |
| 212 | 212 | |
| 213 | - foreach (glob(__DIR__ . "/swagger/" . $this->version . "/*.json") as $swaggerfile) { |
|
| 213 | + foreach (glob(__DIR__."/swagger/".$this->version."/*.json") as $swaggerfile) { |
|
| 214 | 214 | $this->swaggers->push(new Swagger($swaggerfile, $this->version)); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | public function process() |
| 221 | 221 | { |
| 222 | 222 | $this->swaggers->each( |
| 223 | - function (Swagger $swagger) { |
|
| 223 | + function(Swagger $swagger) { |
|
| 224 | 224 | $swagger->parseDefinitions(); |
| 225 | 225 | |
| 226 | 226 | $swagger->parsePaths(); |
@@ -234,30 +234,30 @@ discard block |
||
| 234 | 234 | /** @var Loader $loader */ |
| 235 | 235 | $loader = new Loader(); |
| 236 | 236 | |
| 237 | -foreach (glob(__DIR__ . "/swagger/*") as $version) { |
|
| 237 | +foreach (glob(__DIR__."/swagger/*") as $version) { |
|
| 238 | 238 | $version = basename($version); |
| 239 | 239 | |
| 240 | 240 | echo "Working on version ${version}\n"; |
| 241 | 241 | |
| 242 | 242 | $loader->loadVersion($version) |
| 243 | - ->process()->swaggers->each(function (Swagger $swagger) use ($version) { |
|
| 244 | - $directory = __DIR__ . '/Generated/' . $version; |
|
| 243 | + ->process()->swaggers->each(function(Swagger $swagger) use ($version) { |
|
| 244 | + $directory = __DIR__.'/Generated/'.$version; |
|
| 245 | 245 | |
| 246 | - echo "Writing " . $swagger->getTitle() . "\n"; |
|
| 246 | + echo "Writing ".$swagger->getTitle()."\n"; |
|
| 247 | 247 | |
| 248 | - mkdir($directory . '/' . $swagger->getTitle(), 0755, true); |
|
| 248 | + mkdir($directory.'/'.$swagger->getTitle(), 0755, true); |
|
| 249 | 249 | |
| 250 | - $swagger->models->each(function ($contents, $model) use ($directory, $swagger) { |
|
| 251 | - file_put_contents($directory . '/' . $swagger->getTitle() . '/' . $model . '.php', $contents); |
|
| 250 | + $swagger->models->each(function($contents, $model) use ($directory, $swagger) { |
|
| 251 | + file_put_contents($directory.'/'.$swagger->getTitle().'/'.$model.'.php', $contents); |
|
| 252 | 252 | }); |
| 253 | 253 | |
| 254 | 254 | echo "Appending map\n"; |
| 255 | 255 | |
| 256 | - $map = collect(json_decode(@ file_get_contents($directory . '/map.json'), true)) |
|
| 256 | + $map = collect(json_decode(@ file_get_contents($directory.'/map.json'), true)) |
|
| 257 | 257 | ->merge($swagger->map) |
| 258 | 258 | ->sort(); |
| 259 | 259 | |
| 260 | - file_put_contents($directory . '/map.json', $map->toJson()); |
|
| 260 | + file_put_contents($directory.'/map.json', $map->toJson()); |
|
| 261 | 261 | }); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - trigger_error('Call to undefined method ' . __CLASS__ . '::' . $method . '()', E_USER_ERROR); |
|
| 99 | + trigger_error('Call to undefined method '.__CLASS__.'::'.$method.'()', E_USER_ERROR); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if (class_exists($cast)) { |
| 189 | - return new $cast((array)$value); |
|
| 189 | + return new $cast((array) $value); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if (strcasecmp('json', $cast) == 0) { |
| 193 | - return json_encode((array)$value); |
|
| 193 | + return json_encode((array) $value); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | if (strcasecmp('collection', $cast) == 0) { |
| 197 | - return new Collection((array)$value); |
|
| 197 | + return new Collection((array) $value); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | if (in_array($cast, ['bool', 'boolean'])) { |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | // Allow for making related calls for "extra" properties in the "_info" property. |
| 311 | 311 | // Cache the results so only 1 call is made |
| 312 | - if (!isset($this->{$attribute}) && isset($this->_info->{$attribute . '_href'})) { |
|
| 312 | + if (!isset($this->{$attribute}) && isset($this->_info->{$attribute.'_href'})) { |
|
| 313 | 313 | $this->setAttribute( |
| 314 | 314 | $attribute, |
| 315 | 315 | $this->client->getAll( |
| 316 | - Str::replaceFirst($this->client->getUrl(), '', $this->_info->{$attribute . '_href'}) |
|
| 316 | + Str::replaceFirst($this->client->getUrl(), '', $this->_info->{$attribute.'_href'}) |
|
| 317 | 317 | ) |
| 318 | 318 | ); |
| 319 | 319 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | }; |
| 325 | 325 | |
| 326 | 326 | // Attribute does not exist on the model |
| 327 | - trigger_error('Undefined property:' . __CLASS__ . '::$' . $attribute); |
|
| 327 | + trigger_error('Undefined property:'.__CLASS__.'::$'.$attribute); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | protected function getterMethodName($attribute) |
| 364 | 364 | { |
| 365 | - return 'get' . Str::studly($attribute) . 'Attribute'; |
|
| 365 | + return 'get'.Str::studly($attribute).'Attribute'; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | protected function setterMethodName($attribute) |
| 469 | 469 | { |
| 470 | - return 'set' . Str::studly($attribute) . 'Attribute'; |
|
| 470 | + return 'set'.Str::studly($attribute).'Attribute'; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $this->token->refresh($this); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - return 'Basic ' . base64_encode($this->token->getUsername() . ':' . $this->token->getPassword()); |
|
| 189 | + return 'Basic '.base64_encode($this->token->getUsername().':'.$this->token->getPassword()); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | public function buildUri($resource) |
| 221 | 221 | { |
| 222 | 222 | // TODO: Check to see if resource already starts with Url to not have to trim it |
| 223 | - $uri = $this->getUrl() . ltrim($resource, '/'); |
|
| 223 | + $uri = $this->getUrl().ltrim($resource, '/'); |
|
| 224 | 224 | |
| 225 | 225 | // For getAll calls, make sure to add pageSize & page to request |
| 226 | 226 | if ($this->page) { |
| 227 | - $uri .= (preg_match('/\\?/u', $uri) ? '&' : '?') . 'pageSize=' . $this->page_size . '&page=' . $this->page; |
|
| 227 | + $uri .= (preg_match('/\\?/u', $uri) ? '&' : '?').'pageSize='.$this->page_size.'&page='.$this->page; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | if (strlen($uri) > 2000) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | return array_merge( |
| 285 | 285 | [ |
| 286 | 286 | 'x-cw-usertype' => 'member', |
| 287 | - 'Accept' => 'application/vnd.connectwise.com+json; version=' . $this->getVersion(), |
|
| 287 | + 'Accept' => 'application/vnd.connectwise.com+json; version='.$this->getVersion(), |
|
| 288 | 288 | ], |
| 289 | 289 | $authorization_headers, |
| 290 | 290 | $this->headers |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function getUrl() |
| 320 | 320 | { |
| 321 | - return $this->url . '/v4_6_release/apis/3.0/'; |
|
| 321 | + return $this->url.'/v4_6_release/apis/3.0/'; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | protected function isLastPage(Response $response) |
| 373 | 373 | { |
| 374 | - return !(bool)preg_match('/rel="last"$/u', $response->getHeader('Link')[0] ?? null); |
|
| 374 | + return !(bool) preg_match('/rel="last"$/u', $response->getHeader('Link')[0] ?? null); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | */ |
| 400 | 400 | protected function processResponse($resource, Response $response) |
| 401 | 401 | { |
| 402 | - $response = (array)json_decode($response->getBody(), true); |
|
| 402 | + $response = (array) json_decode($response->getBody(), true); |
|
| 403 | 403 | |
| 404 | 404 | if ($model = $this->resolver->find($resource, $this->getVersion())) { |
| 405 | 405 | if ($this->isCollection($response)) { |
| 406 | 406 | $response = array_map( |
| 407 | - function ($item) use ($model) { |
|
| 407 | + function($item) use ($model) { |
|
| 408 | 408 | $item = new $model($item, $this); |
| 409 | 409 | |
| 410 | 410 | return $item; |