@@ -11,6 +11,6 @@ |
||
11 | 11 | */ |
12 | 12 | public function getConnectWiseMemberIdAttribute() |
13 | 13 | { |
14 | - return str_replace('.', '', explode('@', $this->email)[0]); |
|
14 | + return str_replace('.', '', explode('@', $this->email)[ 0 ]); |
|
15 | 15 | } |
16 | 16 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | ); |
87 | 87 | |
88 | 88 | $client->setIntegrator($app->config->get('services.connectwise.integrator')) |
89 | - ->setPassword($app->config->get('services.connectwise.password')) |
|
90 | - ->setUrl($app->config->get('services.connectwise.url')); |
|
89 | + ->setPassword($app->config->get('services.connectwise.password')) |
|
90 | + ->setUrl($app->config->get('services.connectwise.url')); |
|
91 | 91 | |
92 | 92 | return $client; |
93 | 93 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $token = new Token(); |
122 | 122 | |
123 | 123 | $token->setCompanyId($app->config->get('services.connectwise.company_id')) |
124 | - ->setMemberId($this->determineMemberId()); |
|
124 | + ->setMemberId($this->determineMemberId()); |
|
125 | 125 | |
126 | 126 | return $token; |
127 | 127 | } |
@@ -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 | $client = new Client( |
83 | 83 | $app->make(Token::class), |
84 | 84 | $app->make(Guzzle::class), |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $this->app->singleton( |
119 | 119 | Token::class, |
120 | - function (Application $app) { |
|
120 | + function(Application $app) { |
|
121 | 121 | $token = new Token(); |
122 | 122 | |
123 | 123 | $token->setCompanyId($app->config->get('services.connectwise.company_id')) |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - protected $attributes = []; |
|
29 | + protected $attributes = [ ]; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Properties that need to be casts to a specific object or type |
33 | 33 | * |
34 | 34 | * @var array |
35 | 35 | */ |
36 | - protected $casts = []; |
|
36 | + protected $casts = [ ]; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Client instance to go get related properties |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | { |
77 | 77 | // Call existing method |
78 | 78 | if (method_exists($this, $method)) { |
79 | - return call_user_func_array([$this, $method], $arguments); |
|
79 | + return call_user_func_array([ $this, $method ], $arguments); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Look to see if the property has a relationship to call |
83 | 83 | if ($this->client && is_array($this->{$method}) && array_key_exists('_info', $this->{$method})) { |
84 | - foreach ($this->{$method}['_info'] as $k => $v) { |
|
84 | + foreach ($this->{$method}[ '_info' ] as $k => $v) { |
|
85 | 85 | if (starts_with($v, $this->client->getUrl())) { |
86 | 86 | // Cache so that other request will not trigger additional calls |
87 | 87 | $this->{$method} = $this->client->get(str_replace_first($this->client->getUrl(), '', $v)); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function __unset($attribute) |
138 | 138 | { |
139 | - unset($this->attributes[$attribute]); |
|
139 | + unset($this->attributes[ $attribute ]); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return new Collection((array)$value); |
172 | 172 | } |
173 | 173 | |
174 | - if (in_array($cast, ["bool", "boolean"])) { |
|
174 | + if (in_array($cast, [ "bool", "boolean" ])) { |
|
175 | 175 | return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
176 | 176 | } |
177 | 177 | |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | if (isset($this->$attribute)) { |
273 | - return $this->attributes[$attribute]; |
|
273 | + return $this->attributes[ $attribute ]; |
|
274 | 274 | }; |
275 | 275 | |
276 | - trigger_error('Undefined property:'. __CLASS__ . '::$' . $attribute); |
|
276 | + trigger_error('Undefined property:' . __CLASS__ . '::$' . $attribute); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function getCasts($attribute = null) |
287 | 287 | { |
288 | 288 | if (array_key_exists($attribute, $this->casts)) { |
289 | - return $this->casts[$attribute]; |
|
289 | + return $this->casts[ $attribute ]; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | return $this->casts; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $value = $this->castTo($value, $this->getCasts($attribute)); |
385 | 385 | } |
386 | 386 | |
387 | - $this->attributes[$attribute] = $value; |
|
387 | + $this->attributes[ $attribute ] = $value; |
|
388 | 388 | |
389 | 389 | return $this; |
390 | 390 | } |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @var array |
18 | 18 | */ |
19 | - protected $map = []; |
|
19 | + protected $map = [ ]; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * ModelResolver constructor. |
23 | 23 | * |
24 | 24 | * @param array $map |
25 | 25 | */ |
26 | - public function __construct(array $map = []) |
|
26 | + public function __construct(array $map = [ ]) |
|
27 | 27 | { |
28 | 28 | $this->map = $this->setMap($map); |
29 | 29 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return array |
39 | 39 | */ |
40 | - public function setMap(array $map = []) |
|
40 | + public function setMap(array $map = [ ]) |
|
41 | 41 | { |
42 | 42 | if (!empty($map)) { |
43 | 43 | return $map; |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | $uri_parts = parse_url($uri); |
1149 | 1149 | |
1150 | 1150 | // Trim "/" off the end |
1151 | - $pattern = rtrim($uri_parts['path'], '/'); |
|
1151 | + $pattern = rtrim($uri_parts[ 'path' ], '/'); |
|
1152 | 1152 | |
1153 | 1153 | // Replace /(/)d+(/?)/ with /$1{id}$2/ |
1154 | 1154 | $pattern = preg_replace('|(/)\\d+(/?)|u', '$1{id}$2', $pattern); |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | // TODO: Consider flipping the resource map array to put the resources second to clean this up? |
1162 | 1162 | try { |
1163 | 1163 | return array_values(array_intersect_key($this->map, |
1164 | - array_flip(preg_grep($pattern, array_keys($this->map)))))[0]; |
|
1164 | + array_flip(preg_grep($pattern, array_keys($this->map)))))[ 0 ]; |
|
1165 | 1165 | } catch (Exception $exception) { |
1166 | 1166 | return null; |
1167 | 1167 | } |
@@ -130,7 +130,7 @@ |
||
130 | 130 | { |
131 | 131 | return !is_null($this->expiration) && |
132 | 132 | Carbon::now() |
133 | - ->gte($this->expiration); |
|
133 | + ->gte($this->expiration); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -173,9 +173,9 @@ |
||
173 | 173 | protected function parse($token) |
174 | 174 | { |
175 | 175 | // TODO: Put guard here to make sure that we got a token. |
176 | - $this->setExpiration($token['expiration']); |
|
177 | - $this->password = $token['privateKey']; |
|
178 | - $this->username = $token['publicKey']; |
|
176 | + $this->setExpiration($token[ 'expiration' ]); |
|
177 | + $this->password = $token[ 'privateKey' ]; |
|
178 | + $this->username = $token[ 'publicKey' ]; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @var array |
38 | 38 | */ |
39 | - protected $headers = []; |
|
39 | + protected $headers = [ ]; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Integrator username to make global calls |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | throw new InvalidArgumentException(sprintf("Unsupported verb [%s] was requested.", $verb)); |
120 | 120 | } |
121 | 121 | |
122 | - return $this->request($verb, $args[0], $args[1] ?? []); |
|
122 | + return $this->request($verb, $args[ 0 ], $args[ 1 ] ?? [ ]); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | public function addHeader(array $header) |
133 | 133 | { |
134 | 134 | foreach ($header as $key => $value) { |
135 | - $this->headers[$key] = $value; |
|
135 | + $this->headers[ $key ] = $value; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return $this; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - public function buildOptions(array $options = []) |
|
168 | + public function buildOptions(array $options = [ ]) |
|
169 | 169 | { |
170 | 170 | return array_merge_recursive($options, [ |
171 | 171 | 'auth' => $this->buildAuth(), |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function emptyHeaders() |
194 | 194 | { |
195 | - $this->setHeaders([]); |
|
195 | + $this->setHeaders([ ]); |
|
196 | 196 | |
197 | 197 | return $this; |
198 | 198 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $model = 'Spinen\ConnectWise\Models\\' . $model; |
278 | 278 | |
279 | 279 | if ($this->isCollection($response)) { |
280 | - $response = array_map(function ($item) use ($model) { |
|
280 | + $response = array_map(function($item) use ($model) { |
|
281 | 281 | $item = new $model($item, $this); |
282 | 282 | |
283 | 283 | return $item; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - protected function request($method, $resource, array $options = []) |
|
304 | + protected function request($method, $resource, array $options = [ ]) |
|
305 | 305 | { |
306 | 306 | try { |
307 | 307 | $response = $this->guzzle->request($method, $this->buildUri($resource), $this->buildOptions($options)); |
@@ -16,27 +16,27 @@ discard block |
||
16 | 16 | function determinePropertyType($properties) |
17 | 17 | { |
18 | 18 | if (array_key_exists('format', $properties)) { |
19 | - if ('number' == $properties['type']) { |
|
20 | - return $properties['format']; |
|
19 | + if ('number' == $properties[ 'type' ]) { |
|
20 | + return $properties[ 'format' ]; |
|
21 | 21 | } |
22 | 22 | |
23 | - if ('string' == $properties['type'] && 'date-time' == $properties['format']) { |
|
23 | + if ('string' == $properties[ 'type' ] && 'date-time' == $properties[ 'format' ]) { |
|
24 | 24 | return 'carbon'; |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | - return $properties['type']; |
|
28 | + return $properties[ 'type' ]; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | function getDefinitions($definition) |
32 | 32 | { |
33 | 33 | $definition = preg_replace('|^#/definitions/|u', '', $definition); |
34 | 34 | |
35 | - if (!array_key_exists($definition, $GLOBALS['swagger']['definitions'])) { |
|
35 | + if (!array_key_exists($definition, $GLOBALS[ 'swagger' ][ 'definitions' ])) { |
|
36 | 36 | throw new RuntimeException(sprintf("Unexpected definition [%s]", $definition)); |
37 | 37 | } |
38 | 38 | |
39 | - return $GLOBALS['swagger']['definitions'][$definition]['properties']; |
|
39 | + return $GLOBALS[ 'swagger' ][ 'definitions' ][ $definition ][ 'properties' ]; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function getResponse(array $responses, $code = 200) |
@@ -47,22 +47,22 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | // No schema, so just empty array--no response |
50 | - if (!array_key_exists('schema', $responses[$code])) { |
|
51 | - return []; |
|
50 | + if (!array_key_exists('schema', $responses[ $code ])) { |
|
51 | + return [ ]; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // Essentially not an array of items |
55 | - if (array_key_exists('$ref', $responses[$code]['schema'])) { |
|
56 | - return $responses[$code]['schema']; |
|
55 | + if (array_key_exists('$ref', $responses[ $code ][ 'schema' ])) { |
|
56 | + return $responses[ $code ][ 'schema' ]; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // No items, so just empty array--no response |
60 | - if (!array_key_exists('items', $responses[$code]['schema'])) { |
|
61 | - return []; |
|
60 | + if (!array_key_exists('items', $responses[ $code ][ 'schema' ])) { |
|
61 | + return [ ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // Give back the items |
65 | - return $responses[$code]['schema']['items']; |
|
65 | + return $responses[ $code ][ 'schema' ][ 'items' ]; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function mapResourceToClass($uri, $namespace, $class) |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | function parseResponse($response, $uri) |
74 | 74 | { |
75 | - $attributes = []; |
|
75 | + $attributes = [ ]; |
|
76 | 76 | |
77 | 77 | foreach ($response as $name => $item) { |
78 | 78 | if ('$ref' !== $name) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | // TODO: Handle recursive defs |
87 | 87 | if (!array_key_exists('$ref', $properties)) { |
88 | - $attributes[$attribute] = determinePropertyType($properties); |
|
88 | + $attributes[ $attribute ] = determinePropertyType($properties); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | |
96 | 96 | function processPaths() |
97 | 97 | { |
98 | - $namespace = studly_case($GLOBALS['api']); |
|
98 | + $namespace = studly_case($GLOBALS[ 'api' ]); |
|
99 | 99 | |
100 | 100 | mkdir(__DIR__ . '/Generated/' . $namespace, 0755, true); |
101 | 101 | |
102 | - foreach ($GLOBALS['swagger']['paths'] as $uri => $actions) { |
|
102 | + foreach ($GLOBALS[ 'swagger' ][ 'paths' ] as $uri => $actions) { |
|
103 | 103 | if (array_key_exists('get', $actions)) { |
104 | - $docs = $actions['get']; |
|
105 | - $class = str_singular($docs['tags'][0]); |
|
104 | + $docs = $actions[ 'get' ]; |
|
105 | + $class = str_singular($docs[ 'tags' ][ 0 ]); |
|
106 | 106 | $file = __DIR__ . '/Generated/' . $namespace . '/' . $class . '.php'; |
107 | 107 | |
108 | 108 | mapResourceToClass($uri, $namespace, $class); |
109 | 109 | |
110 | - $attributes = parseResponse(getResponse($docs['responses']), $uri); |
|
110 | + $attributes = parseResponse(getResponse($docs[ 'responses' ]), $uri); |
|
111 | 111 | |
112 | 112 | writeClassFile($file, $namespace, $class, $attributes); |
113 | 113 | } |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | foreach (glob(__DIR__ . "/swagger/*.json") as $swaggerfile) { |
158 | - $GLOBALS['api'] = explode('.', basename($swaggerfile))[0]; |
|
159 | - $GLOBALS['swagger'] = readSwagger($swaggerfile); |
|
158 | + $GLOBALS[ 'api' ] = explode('.', basename($swaggerfile))[ 0 ]; |
|
159 | + $GLOBALS[ 'swagger' ] = readSwagger($swaggerfile); |
|
160 | 160 | |
161 | 161 | processPaths(); |
162 | 162 | } |