Code Duplication    Length = 5-5 lines in 2 locations

includes/api/class-wc-rest-orders-controller.php 2 locations

@@ 594-598 (lines=5) @@
591
	protected function prepare_fee_lines( $posted, $action ) {
592
		$item = new WC_Order_Item_Fee( ! empty( $posted['id'] ) ? $posted['id'] : '' );
593
594
		if ( 'create' === $action ) {
595
			if ( empty( $posted['name'] ) ) {
596
				throw new WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 );
597
			}
598
		}
599
600
		if ( isset( $posted['name'] ) ) {
601
			$item->set_name( $posted['name'] );
@@ 629-633 (lines=5) @@
626
	protected function prepare_coupon_lines( $posted, $action ) {
627
		$item = new WC_Order_Item_Coupon( ! empty( $posted['id'] ) ? $posted['id'] : '' );
628
629
		if ( 'create' === $action ) {
630
			if ( empty( $posted['code'] ) ) {
631
				throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 );
632
			}
633
		}
634
635
		if ( isset( $posted['code'] ) ) {
636
			$item->set_code( $posted['code'] );