Completed
Push — master ( cd772f...00939d )
by Joro
17:23 queued 07:09
created

Hidden_Field::set_hidden()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Carbon_Fields\Field;
4
5
/**
6
 * Hidden field class.
7
 */
8
class Hidden_Field extends Field {
9
10
	protected $hidden = false;
11
12
	/**
13
	 * Get hidden state
14
	 *
15
	 * @return bool
16
	 */
17
	public function get_hidden() {
18
		return $this->hidden;
19
	}
20
21
	/**
22
	 * This states configures if the field is shown in the backend.
23
	 *
24
	 * @param  bool  $hidden
25
	 * @return self  $this
26
	 */
27
	public function set_hidden( $hidden = true ) {
28
		$this->hidden = $hidden;
29
		return $this;
30
	}
31
32
	/**
33
	 * Returns an array that holds the field data, suitable for JSON representation.
34
	 *
35
	 * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
36
	 * @return array
37
	 */
38
	public function to_json( $load ) {
39
		$field_data = parent::to_json( $load );
40
41
		$field_data = array_merge( $field_data, array(
42
			'hidden' => $this->get_hidden()
43
		) );
44
45
		return $field_data;
46
	}
47
}
48