Completed
Push — develop ( 21cbb0...de726d )
by Gennady
19:49
created

GravityView_Field_Pipe_Recorder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A field_options() 0 18 2
1
<?php
2
/**
3
 * @file class-gravityview-field-fileupload.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
class GravityView_Field_Pipe_Recorder extends GravityView_Field {
9
10
	var $name = 'pipe_recorder';
11
12
	var $_gf_field_class_name = 'GF_Field_Pipe_Recorder';
13
14
	var $is_searchable = false;
15
16
	var $group = 'advanced';
17
18
	public function __construct() {
19
		$this->label = esc_html__( 'Pipe Recorder', 'gravityview' );
20
		parent::__construct();
21
	}
22
23
	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
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...
24
25
		unset( $field_options['search_filter'] );
26
27
		if ( 'edit' === $context ) {
28
			return $field_options;
29
		}
30
31
		$add_options['embed'] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$add_options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $add_options = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
32
			'type' => 'checkbox',
33
			'label' => __( 'Display as embedded', 'gravityview' ),
34
			'desc' => __( 'Display the video in a player, rather than a direct link to the video.', 'gravityview' ),
35
			'value' => false,
36
			'merge_tags' => false,
37
		);
38
39
		return $add_options + $field_options;
40
	}
41
}
42
43
new GravityView_Field_Pipe_Recorder;
44