Code Duplication    Length = 16-18 lines in 3 locations

core/helpers/EEH_Line_Item.helper.php 3 locations

@@ 664-680 (lines=17) @@
661
     * @throws InvalidInterfaceException
662
     * @throws ReflectionException
663
     */
664
    public static function create_total_line_item($transaction = null)
665
    {
666
        $total_line_item = EE_Line_Item::new_instance(array(
667
            'LIN_code' => 'total',
668
            'LIN_name' => esc_html__('Grand Total', 'event_espresso'),
669
            'LIN_type' => EEM_Line_Item::type_total,
670
            'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TRANSACTION,
671
        ));
672
        $total_line_item = apply_filters(
673
            'FHEE__EEH_Line_Item__create_total_line_item__total_line_item',
674
            $total_line_item
675
        );
676
        self::set_TXN_ID($total_line_item, $transaction);
677
        self::create_pre_tax_subtotal($total_line_item, $transaction);
678
        self::create_taxes_subtotal($total_line_item, $transaction);
679
        return $total_line_item;
680
    }
681
682
683
    /**
@@ 695-710 (lines=16) @@
692
     * @throws InvalidInterfaceException
693
     * @throws ReflectionException
694
     */
695
    protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = null)
696
    {
697
        $pre_tax_line_item = EE_Line_Item::new_instance(array(
698
            'LIN_code' => 'pre-tax-subtotal',
699
            'LIN_name' => esc_html__('Pre-Tax Subtotal', 'event_espresso'),
700
            'LIN_type' => EEM_Line_Item::type_sub_total,
701
        ));
702
        $pre_tax_line_item = apply_filters(
703
            'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item',
704
            $pre_tax_line_item
705
        );
706
        self::set_TXN_ID($pre_tax_line_item, $transaction);
707
        $total_line_item->add_child_line_item($pre_tax_line_item);
708
        self::create_event_subtotal($pre_tax_line_item, $transaction);
709
        return $pre_tax_line_item;
710
    }
711
712
713
    /**
@@ 726-743 (lines=18) @@
723
     * @throws InvalidInterfaceException
724
     * @throws ReflectionException
725
     */
726
    protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = null)
727
    {
728
        $tax_line_item = EE_Line_Item::new_instance(array(
729
            'LIN_code'  => 'taxes',
730
            'LIN_name'  => esc_html__('Taxes', 'event_espresso'),
731
            'LIN_type'  => EEM_Line_Item::type_tax_sub_total,
732
            'LIN_order' => 1000,// this should always come last
733
        ));
734
        $tax_line_item = apply_filters(
735
            'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item',
736
            $tax_line_item
737
        );
738
        self::set_TXN_ID($tax_line_item, $transaction);
739
        $total_line_item->add_child_line_item($tax_line_item);
740
        // and lastly, add the actual taxes
741
        self::apply_taxes($total_line_item);
742
        return $tax_line_item;
743
    }
744
745
746
    /**