1 | <?php |
||
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 | public function all($endpoint = '', $options = []) |
||
22 | |||
23 | /** |
||
24 | * GET method. |
||
25 | * Retrieve Single data. |
||
26 | * |
||
27 | * @param string $endpoint API endpoint. |
||
28 | * @param array $options |
||
29 | * |
||
30 | * @return array |
||
31 | */ |
||
32 | public function find($endpoint = '', $options = []) |
||
38 | |||
39 | /** |
||
40 | * POST method. |
||
41 | * Insert data. |
||
42 | * |
||
43 | * @param string $endpoint API endpoint. |
||
44 | * @param array $data |
||
45 | * |
||
46 | * @return array |
||
47 | */ |
||
48 | public function create($endpoint, $data) |
||
54 | |||
55 | /** |
||
56 | * PUT method. |
||
57 | * Update data. |
||
58 | * |
||
59 | * @param string $endpoint API endpoint. |
||
60 | * @param array $data |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | public function update($endpoint, $data) |
||
70 | |||
71 | /** |
||
72 | * DELETE method. |
||
73 | * Remove data. |
||
74 | * |
||
75 | * @param string $endpoint API endpoint. |
||
76 | * @param array $options |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | public function delete($endpoint, $options = []) |
||
86 | |||
87 | /** |
||
88 | * Return the last request header. |
||
89 | * |
||
90 | * @return \Automattic\WooCommerce\HttpClient\Request |
||
91 | */ |
||
92 | public function getRequest() |
||
98 | |||
99 | /** |
||
100 | * Return the http response headers from last request. |
||
101 | * |
||
102 | * @return \Automattic\WooCommerce\HttpClient\Response |
||
103 | */ |
||
104 | public function getResponse() |
||
110 | |||
111 | /** |
||
112 | * Count the total results and return it. |
||
113 | * |
||
114 | * @return int |
||
115 | */ |
||
116 | public function countResults() |
||
120 | |||
121 | /** |
||
122 | * Count the total pages and return. |
||
123 | * |
||
124 | * @return mixed |
||
125 | */ |
||
126 | public function countPages() |
||
130 | |||
131 | /** |
||
132 | * Return the current page number. |
||
133 | * |
||
134 | * @return int |
||
135 | */ |
||
136 | public function current() |
||
140 | |||
141 | /** |
||
142 | * Return the previous page number. |
||
143 | * |
||
144 | * @return int|null |
||
145 | */ |
||
146 | public function previous() |
||
152 | |||
153 | /** |
||
154 | * Return the next page number. |
||
155 | * |
||
156 | * @return int|null |
||
157 | */ |
||
158 | public function next() |
||
164 | } |
||
165 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: