Passed
Pull Request — master (#377)
by Brian
06:57
created

GetPaid_Meta_Box_Invoice_Items::output()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 74
Code Lines 65

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 65
c 1
b 0
f 0
dl 0
loc 74
rs 8.7636
cc 3
nc 2
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Invoice Items
5
 *
6
 * Display the invoice items meta box.
7
 *
8
 */
9
10
if ( ! defined( 'ABSPATH' ) ) {
11
	exit; // Exit if accessed directly
12
}
13
14
/**
15
 * GetPaid_Meta_Box_Invoice_Items Class.
16
 */
17
class GetPaid_Meta_Box_Invoice_Items {
18
19
    /**
20
	 * Output the metabox.
21
	 *
22
	 * @param WP_Post $post
23
	 */
24
    public static function output( $post ) {
25
26
        // Prepare the invoice.
27
        $invoice = new WPInv_Invoice( $post );
28
29
        ?>
30
31
        <style>
32
            #poststuff .input-group-text,
33
            #poststuff .form-control {
34
                border-color: #7e8993;
35
            }
36
37
            #wpinv-details label {
38
                margin-bottom: 3px;
39
                font-weight: 600;
40
            }
41
        </style>
42
43
                <div class="bsui" style="margin-top: 1.5rem">
44
45
                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
46
                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
47
48
                        <div class="row">
49
                            <div class="col-12 col-sm-6">
50
                                <?php
51
                                    echo aui()->select(
52
                                        array(
53
                                            'id'          => 'wpinv_template',
54
                                            'name'        => 'wpinv_template',
55
                                            'label'       => __( 'Template', 'invoicing' ),
56
                                            'label_type'  => 'vertical',
57
                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
58
                                            'class'       => 'form-control-sm',
59
                                            'value'       => $invoice->get_template( 'edit' ),
60
                                            'options'     => array(
61
                                                'quantity' => __( 'Quantity', 'invoicing' ),
62
                                                'hours'    => __( 'Hours', 'invoicing' ),
63
                                                'amount'   => __( 'Amount Only', 'invoicing' ),
64
                                            ),
65
                                            'data-allow-clear' => 'false',
66
                                            'select2'          => true,
67
                                        )
68
                                    );
69
                                ?>
70
                            </div>
71
                            <div class="col-12 col-sm-6">
72
                                <?php
73
74
                                    // Set currency.
75
                                    echo aui()->select(
76
                                        array(
77
                                            'id'          => 'wpinv_currency',
78
                                            'name'        => 'wpinv_currency',
79
                                            'label'       => __( 'Currency', 'invoicing' ),
80
                                            'label_type'  => 'vertical',
81
                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
82
                                            'class'       => 'form-control-sm',
83
                                            'value'       => $invoice->get_currency( 'edit' ),
84
                                            'required'    => false,
85
                                            'data-allow-clear' => 'false',
86
                                            'select2'          => true,
87
                                            'options'     => wpinv_get_currencies(),
88
                                        )
89
                                    );
90
91
                                ?>
92
                            </div>
93
                        </div>
94
95
                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
96
                    <?php endif; ?>
97
98
                </div>
99
100
        <?php
101
    }
102
}
103