Skip to content

Commit 0a6e2df

Browse files
committed
braces around all if statements. removed unnecessary isset checks
1 parent 966f459 commit 0a6e2df

5 files changed

Lines changed: 40 additions & 20 deletions

File tree

src/Bigcommerce/Api/Client.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ public static function getCount($path)
226226
{
227227
$response = self::connection()->get(self::$api_path . $path);
228228

229-
if ($response == false || is_string($response)) return $response;
229+
if ($response == false || is_string($response)) {
230+
return $response;
231+
}
230232

231233
return $response->count;
232234
}
@@ -240,7 +242,9 @@ public static function getCount($path)
240242
*/
241243
public static function createResource($path, $object)
242244
{
243-
if (is_array($object)) $object = (object)$object;
245+
if (is_array($object)) {
246+
$object = (object)$object;
247+
}
244248

245249
return self::connection()->post(self::$api_path . $path, $object);
246250
}
@@ -254,7 +258,9 @@ public static function createResource($path, $object)
254258
*/
255259
public static function updateResource($path, $object)
256260
{
257-
if (is_array($object)) $object = (object)$object;
261+
if (is_array($object)) {
262+
$object = (object)$object;
263+
}
258264

259265
return self::connection()->put(self::$api_path . $path, $object);
260266
}
@@ -279,7 +285,9 @@ public static function deleteResource($path)
279285
*/
280286
private static function mapCollection($resource, $object)
281287
{
282-
if ($object == false || is_string($object)) return $object;
288+
if ($object == false || is_string($object)) {
289+
return $object;
290+
}
283291

284292
$baseResource = __NAMESPACE__ . '\\' . $resource;
285293
self::$resource = (class_exists($baseResource)) ? $baseResource : 'Bigcommerce\\Api\\Resources\\' . $resource;
@@ -309,7 +317,9 @@ private static function mapCollectionObject($object)
309317
*/
310318
private static function mapResource($resource, $object)
311319
{
312-
if ($object == false || is_string($object)) return $object;
320+
if ($object == false || is_string($object)) {
321+
return $object;
322+
}
313323

314324
$baseResource = __NAMESPACE__ . '\\' . $resource;
315325
$class = (class_exists($baseResource)) ? $baseResource : 'Bigcommerce\\Api\\Resources\\' . $resource;
@@ -325,7 +335,9 @@ private static function mapResource($resource, $object)
325335
*/
326336
private static function mapCount($object)
327337
{
328-
if ($object == false || is_string($object)) return $object;
338+
if ($object == false || is_string($object)) {
339+
return $object;
340+
}
329341

330342
return $object->count;
331343
}
@@ -339,7 +351,9 @@ public static function getTime()
339351
{
340352
$response = self::connection()->get(self::$api_path . '/time');
341353

342-
if ($response == false || is_string($response)) return $response;
354+
if ($response == false || is_string($response)) {
355+
return $response;
356+
}
343357

344358
return new \DateTime("@{$response->time}");
345359
}
@@ -1152,7 +1166,9 @@ public static function getRequestsRemaining()
11521166
if (!$limit) {
11531167
$result = self::getTime();
11541168

1155-
if (!$result) return false;
1169+
if (!$result) {
1170+
return false;
1171+
}
11561172

11571173
$limit = self::connection()->getHeader('X-BC-ApiLimit-Remaining');
11581174
}

src/Bigcommerce/Api/Connection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ private function followRedirectPath()
270270
$this->redirectsFollowed++;
271271

272272
if ($this->getStatus() == 301 || $this->getStatus() == 302) {
273-
274273
if ($this->redirectsFollowed < $this->maxRedirects) {
275-
276274
$location = $this->getHeader('Location');
277275
$forwardTo = parse_url($location);
278276

src/Bigcommerce/Api/NetworkError.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88
class NetworkError extends Error
99
{
10-
11-
}
10+
}

src/Bigcommerce/Api/Resource.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getCreateFields()
7171
$resource = $this->fields;
7272

7373
foreach ($this->ignoreOnCreate as $field) {
74-
if (isset($resource->$field)) unset($resource->$field);
74+
unset($resource->$field);
7575
}
7676

7777
return $resource;
@@ -82,23 +82,31 @@ public function getUpdateFields()
8282
$resource = $this->fields;
8383

8484
foreach ($this->ignoreOnUpdate as $field) {
85-
if (isset($resource->$field)) unset($resource->$field);
85+
unset($resource->$field);
8686
}
8787

8888
foreach ($resource as $field => $value) {
89-
if ($this->isIgnoredField($field, $value)) unset($resource->$field);
89+
if ($this->isIgnoredField($field, $value)) {
90+
unset($resource->$field);
91+
}
9092
}
9193

9294
return $resource;
9395
}
9496

9597
private function isIgnoredField($field, $value)
9698
{
97-
if ($value === null) return true;
99+
if ($value === null) {
100+
return true;
101+
}
98102

99-
if ((strpos($field, "date") !== FALSE) && $value === "") return true;
103+
if (strpos($field, "date") !== false && $value === "") {
104+
return true;
105+
}
100106

101-
if (in_array($field, $this->ignoreIfZero) && $value === 0) return true;
107+
if (in_array($field, $this->ignoreIfZero, true) && $value === 0) {
108+
return true;
109+
}
102110

103111
return false;
104112
}

src/Bigcommerce/Api/ServerError.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88
class ServerError extends Error
99
{
10-
11-
}
10+
}

0 commit comments

Comments
 (0)