Code Duplication    Length = 8-9 lines in 2 locations

includes/api/class-wpinv-rest-items-controller.php 1 location

@@ 679-686 (lines=8) @@
676
		$prepared_item = new stdClass();
677
678
		// Post ID.
679
		if ( isset( $request['id'] ) ) {
680
			$existing_item = $this->get_post( $request['id'] );
681
			if ( is_wp_error( $existing_item ) ) {
682
				return $existing_item;
683
			}
684
685
			$prepared_item->ID 		  = $existing_item->ID;
686
		}
687
688
		$schema = $this->get_item_schema();
689

includes/api/class-wpinv-rest-invoice-controller.php 1 location

@@ 633-641 (lines=9) @@
630
		$prepared_invoice = new stdClass();
631
632
		// Post ID.
633
		if ( isset( $request['id'] ) ) {
634
			$existing_invoice = $this->get_post( $request['id'] );
635
			if ( is_wp_error( $existing_invoice ) ) {
636
				return $existing_invoice;
637
			}
638
639
			$prepared_invoice->ID 		  = $existing_invoice->ID;
640
			$prepared_invoice->invoice_id = $existing_invoice->ID;
641
		}
642
643
		$schema = $this->get_item_schema();
644