Field.php
927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace ACA\ACF;
use http\Exception\InvalidArgumentException;
class Field {
/**
* @var array
*/
protected $settings;
public function __construct( array $settings ) {
$this->settings = $settings;
$this->validate();
}
public function validate() {
if ( ! isset( $this->settings['label'], $this->settings['type'], $this->settings['name'], $this->settings['key'] ) ) {
throw new InvalidArgumentException( 'Missing field argument.' );
}
}
public function is_required() {
return isset( $this->settings['required'] ) && $this->settings['required'];
}
public function get_settings() {
return $this->settings;
}
public function get_label() {
return $this->settings['label'];
}
public function get_type() {
return $this->settings['type'];
}
public function get_meta_key() {
return $this->settings['name'];
}
public function get_hash() {
return $this->settings['key'];
}
}