This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Codexshaper\WooCommerce\PHP\Traits; |
||
4 | |||
5 | trait WooCommerceTrait |
||
6 | { |
||
7 | /** |
||
8 | * GET method. |
||
9 | * Retrieve data. |
||
10 | * |
||
11 | * @param string $endpoint API endpoint. |
||
12 | * @param array $options |
||
13 | * |
||
14 | * @return array |
||
15 | */ |
||
16 | View Code Duplication | public function all($endpoint = '', $options = []) |
|
0 ignored issues
–
show
|
|||
17 | { |
||
18 | try { |
||
19 | self::instance(); |
||
20 | |||
21 | return self::$client->get($endpoint, $options); |
||
22 | } catch (\Exception $e) { |
||
23 | throw new \Exception($e->getMessage(), 1); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * GET method. |
||
29 | * Retrieve Single data. |
||
30 | * |
||
31 | * @param string $endpoint API endpoint. |
||
32 | * @param array $options |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | View Code Duplication | public function find($endpoint = '', $options = []) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
37 | { |
||
38 | try { |
||
39 | self::instance(); |
||
40 | |||
41 | return self::$client->get($endpoint, $options); |
||
42 | } catch (\Exception $e) { |
||
43 | throw new \Exception($e->getMessage(), 1); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * POST method. |
||
49 | * Insert data. |
||
50 | * |
||
51 | * @param string $endpoint API endpoint. |
||
52 | * @param array $data |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | View Code Duplication | public function create($endpoint, $data) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
57 | { |
||
58 | try { |
||
59 | self::instance(); |
||
60 | |||
61 | return self::$client->post($endpoint, $data); |
||
62 | } catch (\Exception $e) { |
||
63 | throw new \Exception($e->getMessage(), 1); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * PUT method. |
||
69 | * Update data. |
||
70 | * |
||
71 | * @param string $endpoint API endpoint. |
||
72 | * @param array $data |
||
73 | * |
||
74 | * @return array |
||
75 | */ |
||
76 | View Code Duplication | public function update($endpoint, $data) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
77 | { |
||
78 | try { |
||
79 | self::instance(); |
||
80 | |||
81 | return self::$client->put($endpoint, $data); |
||
82 | } catch (\Exception $e) { |
||
83 | throw new \Exception($e->getMessage(), 1); |
||
84 | } |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * DELETE method. |
||
89 | * Remove data. |
||
90 | * |
||
91 | * @param string $endpoint API endpoint. |
||
92 | * @param array $options |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | View Code Duplication | public function delete($endpoint, $options = []) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
97 | { |
||
98 | try { |
||
99 | self::instance(); |
||
100 | |||
101 | return self::$client->delete($endpoint, $options); |
||
102 | } catch (\Exception $e) { |
||
103 | throw new \Exception($e->getMessage(), 1); |
||
104 | } |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Return the last request header. |
||
109 | * |
||
110 | * @return \Automattic\WooCommerce\HttpClient\Request |
||
111 | */ |
||
112 | public function getRequest() |
||
113 | { |
||
114 | try { |
||
115 | return self::$client->http->getRequest(); |
||
116 | } catch (\Exception $e) { |
||
117 | throw new \Exception($e->getMessage(), 1); |
||
118 | } |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Return the http response headers from last request. |
||
123 | * |
||
124 | * @return \Automattic\WooCommerce\HttpClient\Response |
||
125 | */ |
||
126 | public function getResponse() |
||
127 | { |
||
128 | try { |
||
129 | return self::$client->http->getResponse(); |
||
130 | } catch (\Exception $e) { |
||
131 | throw new \Exception($e->getMessage(), 1); |
||
132 | } |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Count the total results and return it. |
||
137 | * |
||
138 | * @return int |
||
139 | */ |
||
140 | public function countResults() |
||
141 | { |
||
142 | return (int) static::getResponse()->getHeaders()[self::$headers['header_total']]; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * Count the total pages and return. |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | public function countPages() |
||
151 | { |
||
152 | return (int) static::getResponse()->getHeaders()[self::$headers['header_total_pages']]; |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * Return the current page number. |
||
157 | * |
||
158 | * @return int |
||
159 | */ |
||
160 | public function current() |
||
161 | { |
||
162 | return !empty(static::getRequest()->getParameters()['page']) ? static::getRequest()->getParameters()['page'] : 1; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * Return the previous page number. |
||
167 | * |
||
168 | * @return int|null |
||
169 | */ |
||
170 | public function previous() |
||
171 | { |
||
172 | $currentPage = static::current(); |
||
173 | |||
174 | return ($currentPage-- > 1) ? $currentPage : null; |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * Return the next page number. |
||
179 | * |
||
180 | * @return int|null |
||
181 | */ |
||
182 | public function next() |
||
183 | { |
||
184 | $currentPage = static::current(); |
||
185 | |||
186 | return ($currentPage++ < static::countPages()) ? $currentPage : null; |
||
187 | } |
||
188 | } |
||
189 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.