Code Duplication    Length = 23-25 lines in 8 locations

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

@@ 71-93 (lines=23) @@
68
	 * @param int $page
69
	 * @return array
70
	 */
71
	public function get_orders( $fields = null, $filter = array(), $status = null, $page = 1 ) {
72
73
		if ( ! empty( $status ) )
74
			$filter['status'] = $status;
75
76
		$filter['page'] = $page;
77
78
		$query = $this->query_orders( $filter );
79
80
		$orders = array();
81
82
		foreach( $query->posts as $order_id ) {
83
84
			if ( ! $this->is_readable( $order_id ) )
85
				continue;
86
87
			$orders[] = current( $this->get_order( $order_id, $fields ) );
88
		}
89
90
		$this->server->add_pagination_headers( $query );
91
92
		return array( 'orders' => $orders );
93
	}
94
95
96
	/**

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

@@ 70-92 (lines=23) @@
67
	 * @param int $page
68
	 * @return array
69
	 */
70
	public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) {
71
72
		if ( ! empty( $type ) )
73
			$filter['type'] = $type;
74
75
		$filter['page'] = $page;
76
77
		$query = $this->query_products( $filter );
78
79
		$products = array();
80
81
		foreach( $query->posts as $product_id ) {
82
83
			if ( ! $this->is_readable( $product_id ) )
84
				continue;
85
86
			$products[] = current( $this->get_product( $product_id, $fields ) );
87
		}
88
89
		$this->server->add_pagination_headers( $query );
90
91
		return array( 'products' => $products );
92
	}
93
94
	/**
95
	 * Get the product for the given ID

includes/api/legacy/v2/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/legacy/v2/class-wc-api-products.php 1 location

@@ 110-134 (lines=25) @@
107
	 * @param int $page
108
	 * @return array
109
	 */
110
	public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) {
111
112
		if ( ! empty( $type ) ) {
113
			$filter['type'] = $type;
114
		}
115
116
		$filter['page'] = $page;
117
118
		$query = $this->query_products( $filter );
119
120
		$products = array();
121
122
		foreach ( $query->posts as $product_id ) {
123
124
			if ( ! $this->is_readable( $product_id ) ) {
125
				continue;
126
			}
127
128
			$products[] = current( $this->get_product( $product_id, $fields ) );
129
		}
130
131
		$this->server->add_pagination_headers( $query );
132
133
		return array( 'products' => $products );
134
	}
135
136
	/**
137
	 * Get the product for the given ID

includes/api/legacy/v2/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/legacy/v3/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/legacy/v3/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

includes/api/legacy/v3/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