Skip to content

Commit 2bf615d

Browse files
authored
Merge pull request #24 from Codexshaper/analysis-ajL5wk
Apply fixes from StyleCI
2 parents 29356cc + caec8bf commit 2bf615d

File tree

3 files changed

+15
-49
lines changed

3 files changed

+15
-49
lines changed

src/Traits/QueryBuilderTrait.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trait QueryBuilderTrait
2828
*/
2929
protected function all($options = [])
3030
{
31-
return WooCommerce::all($this->endpoint, $options);
31+
return WooCommerce::all($this->endpoint, $options);
3232
}
3333

3434
/**
@@ -66,7 +66,7 @@ protected function create($data)
6666
*/
6767
protected function update($id, $data)
6868
{
69-
return WooCommerce::update("{$this->endpoint}/{$id}", $data);
69+
return WooCommerce::update("{$this->endpoint}/{$id}", $data);
7070
}
7171

7272
/**
@@ -102,7 +102,6 @@ protected function batch($data)
102102
protected function get()
103103
{
104104
try {
105-
106105
$results = WooCommerce::all($this->endpoint, $this->options);
107106

108107
if (empty($this->where)) {
@@ -123,10 +122,8 @@ protected function get()
123122
}
124123

125124
return $filteredResults;
126-
127-
}catch( \Exception $ex) {
125+
} catch (\Exception $ex) {
128126
throw new \Exception($ex->getMessage(), 1);
129-
130127
}
131128
}
132129

@@ -137,7 +134,7 @@ protected function get()
137134
*/
138135
protected function first()
139136
{
140-
return $this->get()[0] ?? new \stdClass;
137+
return $this->get()[0] ?? new \stdClass();
141138
}
142139

143140
/**
@@ -149,7 +146,6 @@ protected function first()
149146
*/
150147
protected function options($parameters)
151148
{
152-
153149
if (!is_array($parameters)) {
154150
throw new \Exception('Options must be an array', 1);
155151
}
@@ -225,7 +221,6 @@ protected function orderBy($name, $direction = 'desc')
225221
protected function paginate($per_page, $current_page = 1)
226222
{
227223
try {
228-
229224
$this->options['per_page'] = (int) $per_page;
230225

231226
if ($current_page > 0) {
@@ -252,10 +247,8 @@ protected function paginate($per_page, $current_page = 1)
252247
$results['pagination'] = $pagination;
253248

254249
return $results;
255-
256-
}catch( \Exception $ex) {
250+
} catch (\Exception $ex) {
257251
throw new \Exception($ex->getMessage(), 1);
258-
259252
}
260253
}
261254

@@ -267,15 +260,12 @@ protected function paginate($per_page, $current_page = 1)
267260
protected function count()
268261
{
269262
try {
270-
271263
$results = WooCommerce::all($this->endpoint, $this->options);
272264
$totalResults = WooCommerce::countResults();
273265

274266
return $totalResults;
275-
276-
}catch( \Exception $ex) {
267+
} catch (\Exception $ex) {
277268
throw new \Exception($ex->getMessage(), 1);
278-
279269
}
280270
}
281271

@@ -287,6 +277,7 @@ protected function count()
287277
public function save()
288278
{
289279
$this->results = WooCommerce::create($this->endpoint, $this->properties);
280+
290281
return $this->results;
291282
}
292283
}

src/Traits/WooCommerceTrait.php

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ trait WooCommerceTrait
1616
public function all($endpoint = '', $options = [])
1717
{
1818
try {
19-
2019
self::__construct();
2120

2221
return $this->client->get($endpoint, $options);
23-
24-
}catch( \Exception $ex) {
22+
} catch (\Exception $ex) {
2523
throw new \Exception($ex->getMessage(), 1);
26-
2724
}
2825
}
2926

@@ -39,14 +36,11 @@ public function all($endpoint = '', $options = [])
3936
public function find($endpoint = '', $options = [])
4037
{
4138
try {
42-
4339
self::__construct();
4440

4541
return $this->client->get($endpoint, $options);
46-
47-
}catch( \Exception $ex) {
42+
} catch (\Exception $ex) {
4843
throw new \Exception($ex->getMessage(), 1);
49-
5044
}
5145
}
5246

@@ -62,14 +56,11 @@ public function find($endpoint = '', $options = [])
6256
public function create($endpoint, $data)
6357
{
6458
try {
65-
6659
self::__construct();
6760

6861
return $this->client->post($endpoint, $data);
69-
70-
}catch( \Exception $ex) {
62+
} catch (\Exception $ex) {
7163
throw new \Exception($ex->getMessage(), 1);
72-
7364
}
7465
}
7566

@@ -85,14 +76,11 @@ public function create($endpoint, $data)
8576
public function update($endpoint, $data)
8677
{
8778
try {
88-
8979
self::__construct();
9080

9181
return $this->client->put($endpoint, $data);
92-
93-
}catch( \Exception $ex) {
82+
} catch (\Exception $ex) {
9483
throw new \Exception($ex->getMessage(), 1);
95-
9684
}
9785
}
9886

@@ -108,14 +96,11 @@ public function update($endpoint, $data)
10896
public function delete($endpoint, $options = [])
10997
{
11098
try {
111-
11299
self::__construct();
113100

114101
return $this->client->delete($endpoint, $options);
115-
116-
}catch( \Exception $ex) {
102+
} catch (\Exception $ex) {
117103
throw new \Exception($ex->getMessage(), 1);
118-
119104
}
120105
}
121106

@@ -127,12 +112,9 @@ public function delete($endpoint, $options = [])
127112
public function getRequest()
128113
{
129114
try {
130-
131115
return $this->client->http->getRequest();
132-
133-
}catch( \Exception $ex) {
116+
} catch (\Exception $ex) {
134117
throw new \Exception($ex->getMessage(), 1);
135-
136118
}
137119
}
138120

@@ -144,12 +126,9 @@ public function getRequest()
144126
public function getResponse()
145127
{
146128
try {
147-
148129
return $this->client->http->getResponse();
149-
150-
}catch( \Exception $ex) {
130+
} catch (\Exception $ex) {
151131
throw new \Exception($ex->getMessage(), 1);
152-
153132
}
154133
}
155134

src/WooCommerceApi.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class WooCommerceApi
2222
public function __construct()
2323
{
2424
try {
25-
2625
$this->client = new Client(
2726
config('woocommerce.store_url'),
2827
config('woocommerce.consumer_key'),
@@ -35,11 +34,8 @@ public function __construct()
3534
'timeout' => config('woocommerce.timeout'),
3635
]
3736
);
38-
39-
}catch( \Exception $ex) {
37+
} catch (\Exception $ex) {
4038
throw new \Exception($ex->getMessage(), 1);
41-
4239
}
43-
4440
}
4541
}

0 commit comments

Comments
 (0)