Passed
Pull Request — master (#444)
by Brian
10:32
created

GetPaid_Reports_Report::display()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.7
1
<?php
2
/**
3
 * Contains the class that displays a single report.
4
 *
5
 *
6
 */
7
8
defined( 'ABSPATH' ) || exit;
9
10
/**
11
 * GetPaid_Reports_Report Class.
12
 */
13
class GetPaid_Reports_Report {
14
15
	/**
16
	 * @var array
17
	 */
18
	public $views;
19
20
	/**
21
	 * Class constructor.
22
	 *
23
	 */
24
	public function __construct() {
25
26
		$this->views        = array(
27
28
            'items'     => array(
29
				'label' => __( 'Items', 'invoicing' ),
30
				'class' => 'GetPaid_Reports_Report_Items',
31
			),
32
33
			'gateways'  => array(
34
				'label' => __( 'Payment Methods', 'invoicing' ),
35
				'class' => 'GetPaid_Reports_Report_Gateways',
36
			),
37
38
        );
39
40
		$this->views        = apply_filters( 'wpinv_report_views', $this->views );
41
42
	}
43
44
	/**
45
	 * Displays the reports tab.
46
	 *
47
	 */
48
	public function display() {
49
		?>
50
51
		<div class="mt-4" style="max-width: 1200px;">
52
53
			<div class="row">
54
				<div class="col-12 col-md-8">
55
					<?php echo $this->display_left(); ?>
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->display_left() targeting GetPaid_Reports_Report::display_left() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
56
				</div>
57
58
				<div class="col-12 col-md-4">
59
					<?php echo $this->display_right(); ?>
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->display_right() targeting GetPaid_Reports_Report::display_right() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
60
				</div>
61
			</div>
62
63
		</div>
64
65
		<?php
66
67
	}
68
69
	/**
70
	 * Displays the left side.
71
	 *
72
	 */
73
	public function display_left() {
74
		$earnings = new GetPaid_Reports_Report_Earnings();
75
		$earnings->display();
76
	}
77
78
	/**
79
	 * Displays the right side.
80
	 *
81
	 */
82
	public function display_right() {
83
84
		?>
85
86
			<?php foreach ( $this->views as $view ) : ?>
87
				<div class="row mb-4">
88
					<div class="col-12">
89
						<div class="card m-0 p-0" style="max-width:100%">
90
							<div class="card-header">
91
								<strong><?php echo $view['label']; ?></strong>
92
							</div>
93
							<div class="card-body">
94
								<?php
95
									$class = $view['class'];
96
									$class = new $class();
97
									$class->display_stats();
98
								?>
99
							</div>
100
						</div>
101
					</div>
102
				</div>
103
			<?php endforeach; ?>
104
105
		<?php
106
107
	}
108
109
}
110