Completed
Push — issues/1038 ( b40dc2 )
by Ravinder
17:16
created

Give_Form_API::is_button()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 12 and the first side effect is on line 112.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * Form API
5
 *
6
 * @package     Give
7
 * @subpackage  Classes/Give_Form_API
8
 * @copyright   Copyright (c) 2016, WordImpress
9
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
10
 * @since       1.9
11
 */
12
class Give_Form_API {
13
14
	/**
15
	 * The defaults for all elements
16
	 *
17
	 * @since  1.9
18
	 * @access static
19
	 */
20
	static $field_defaults = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $field_defaults.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
21
		'name'       => '',
22
		'desc'       => '',
23
		'id'         => '',
24
		'type'       => '',
25
		'default'    => '',
26
		'data_type'  => '',
27
		'options'    => array(),
28
		'attributes' => array(),
29
	);
30
31
	/**
32
	 * Initialize this module
33
	 *
34
	 * @since  1.9
35
	 * @access static
36
	 */
37
	static function init() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
38
	}
39
40
41
	/**
42
	 * Return HTML with tag $tagname and keyed attrs $attrs.
43
	 *
44
	 * @since  1.9
45
	 * @access static
46
	 */
47
	static function make_tag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
48
	}
49
50
	/**
51
	 * Get elements from a form.
52
	 *
53
	 * @since  1.9
54
	 * @access static
55
	 *
56
	 * @param array $form
57
	 */
58
	static function get_elements( $form ) {
0 ignored issues
show
Unused Code introduced by
The parameter $form is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
59
	}
60
61
	/**
62
	 * Is the element a button?
63
	 *
64
	 * @since  1.9
65
	 * @access static
66
	 *
67
	 * @param array $element
68
	 *
69
	 * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
70
	 */
71
	static function is_button( $element ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
72
		return preg_match( '/^button|submit$/', $element['#type'] );
73
	}
74
75
	/**
76
	 * Render forms.
77
	 *
78
	 * @since  1.9
79
	 * @access static
80
	 */
81
	static function render_form() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
82
	}
83
84
	/**
85
	 * Render an element
86
	 * @since  1.9
87
	 * @access static
88
	 */
89
	static function render_element() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
90
	}
91
92
	/**
93
	 * Process a form, filling in $values with what's been posted
94
	 *
95
	 * @since  1.9
96
	 * @access static
97
	 */
98
	static function process_form() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
99
	}
100
101
	/**
102
	 * Recursively process a meta form element, filling in $values accordingly
103
	 *
104
	 * @since  1.9
105
	 * @access static
106
	 */
107
	static function process_element() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
108
	}
109
}
110
111
// Initialize field API.
112
add_action( 'init', array( 'Give_Form_API', 'init' ) );