Code Duplication    Length = 12-12 lines in 3 locations

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

@@ 543-554 (lines=12) @@
540
	 * @param stdClass $tax Tax object.
541
	 * @return array Links for the given tax.
542
	 */
543
	protected function prepare_links( $tax ) {
544
		$links = array(
545
			'self' => array(
546
				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $tax->tax_rate_id ) ),
547
			),
548
			'collection' => array(
549
				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
550
			),
551
		);
552
553
		return $links;
554
	}
555
556
	/**
557
	 * Get the Taxes schema, conforming to JSON Schema.

includes/abstracts/abstract-wc-rest-posts-controller.php 1 location

@@ 475-486 (lines=12) @@
472
	 * @param WP_Post $post Post object.
473
	 * @return array Links for the given post.
474
	 */
475
	protected function prepare_links( $post ) {
476
		$links = array(
477
			'self' => array(
478
				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ),
479
			),
480
			'collection' => array(
481
				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
482
			),
483
		);
484
485
		return $links;
486
	}
487
488
	/**
489
	 * Determine the allowed query_vars for a get_items() response and

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

@@ 582-593 (lines=12) @@
579
	 * @param WP_User $customer Customer object.
580
	 * @return array Links for the given customer.
581
	 */
582
	protected function prepare_links( $customer ) {
583
		$links = array(
584
			'self' => array(
585
				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $customer->ID ) ),
586
			),
587
			'collection' => array(
588
				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
589
			),
590
		);
591
592
		return $links;
593
	}
594
595
	/**
596
	 * Get the Customer's schema, conforming to JSON Schema.