Code Duplication    Length = 13-13 lines in 3 locations

includes/api/class-wc-rest-product-attributes-controller.php 1 location

@@ 499-511 (lines=13) @@
496
	 * @param object $attribute Attribute object.
497
	 * @return array Links for the given attribute.
498
	 */
499
	protected function prepare_links( $attribute ) {
500
		$base  = '/' . $this->namespace . '/' . $this->rest_base;
501
		$links = array(
502
			'self' => array(
503
				'href' => rest_url( trailingslashit( $base ) . $attribute->attribute_id ),
504
			),
505
			'collection' => array(
506
				'href' => rest_url( $base ),
507
			),
508
		);
509
510
		return $links;
511
	}
512
513
	/**
514
	 * Get the Attribute's schema, conforming to JSON Schema.

includes/api/class-wc-rest-settings-options-controller.php 1 location

@@ 262-274 (lines=13) @@
259
	 * @param string $group_id Group ID.
260
	 * @return array Links for the given setting.
261
	 */
262
	protected function prepare_links( $setting_id, $group_id ) {
263
		$base  = '/' . $this->namespace . '/' . $this->rest_base . '/' . $group_id;
264
		$links = array(
265
			'self' => array(
266
				'href' => rest_url( trailingslashit( $base ) . $setting_id ),
267
			),
268
			'collection' => array(
269
				'href' => rest_url( $base ),
270
			),
271
		);
272
273
		return $links;
274
	}
275
276
	/**
277
	 * Makes sure the current user has access to READ the settings APIs.

includes/api/class-wc-rest-shipping-zone-locations-controller.php 1 location

@@ 125-137 (lines=13) @@
122
	 * @param int $zone_id Given Shipping Zone ID.
123
	 * @return array Links for the given Shipping Zone Location.
124
	 */
125
	protected function prepare_links( $zone_id ) {
126
		$base  = '/' . $this->namespace . '/' . $this->rest_base . '/' . $zone_id;
127
		$links = array(
128
			'collection' => array(
129
				'href' => rest_url( $base . '/locations' ),
130
			),
131
			'describes'  => array(
132
				'href' => rest_url( $base ),
133
			),
134
		);
135
136
		return $links;
137
	}
138
139
	/**
140
	 * Get the Shipping Zone Locations schema, conforming to JSON Schema