Code Duplication    Length = 25-25 lines in 3 locations

includes/api/class-wc-api-orders.php 1 location

@@ 106-130 (lines=25) @@
103
	 * @param int $page
104
	 * @return array
105
	 */
106
	public function get_orders( $fields = null, $filter = array(), $status = null, $page = 1 ) {
107
108
		if ( ! empty( $status ) ) {
109
			$filter['status'] = $status;
110
		}
111
112
		$filter['page'] = $page;
113
114
		$query = $this->query_orders( $filter );
115
116
		$orders = array();
117
118
		foreach ( $query->posts as $order_id ) {
119
120
			if ( ! $this->is_readable( $order_id ) ) {
121
				continue;
122
			}
123
124
			$orders[] = current( $this->get_order( $order_id, $fields, $filter ) );
125
		}
126
127
		$this->server->add_pagination_headers( $query );
128
129
		return array( 'orders' => $orders );
130
	}
131
132
133
	/**

includes/api/class-wc-api-webhooks.php 1 location

@@ 71-95 (lines=25) @@
68
	 * @param int $page
69
	 * @return array
70
	 */
71
	public function get_webhooks( $fields = null, $filter = array(), $status = null, $page = 1 ) {
72
73
		if ( ! empty( $status ) ) {
74
			$filter['status'] = $status;
75
		}
76
77
		$filter['page'] = $page;
78
79
		$query = $this->query_webhooks( $filter );
80
81
		$webhooks = array();
82
83
		foreach ( $query->posts as $webhook_id ) {
84
85
			if ( ! $this->is_readable( $webhook_id ) ) {
86
				continue;
87
			}
88
89
			$webhooks[] = current( $this->get_webhook( $webhook_id, $fields ) );
90
		}
91
92
		$this->server->add_pagination_headers( $query );
93
94
		return array( 'webhooks' => $webhooks );
95
	}
96
97
	/**
98
	 * Get the webhook for the given ID

includes/api/class-wc-api-products.php 1 location

@@ 147-171 (lines=25) @@
144
	 * @param int $page
145
	 * @return array
146
	 */
147
	public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) {
148
149
		if ( ! empty( $type ) ) {
150
			$filter['type'] = $type;
151
		}
152
153
		$filter['page'] = $page;
154
155
		$query = $this->query_products( $filter );
156
157
		$products = array();
158
159
		foreach ( $query->posts as $product_id ) {
160
161
			if ( ! $this->is_readable( $product_id ) ) {
162
				continue;
163
			}
164
165
			$products[] = current( $this->get_product( $product_id, $fields ) );
166
		}
167
168
		$this->server->add_pagination_headers( $query );
169
170
		return array( 'products' => $products );
171
	}
172
173
	/**
174
	 * Get the product for the given ID