Completed
Branch FET/reg-form-builder/extract-a... (6e8a58)
by
unknown
35:36 queued 25:38
created

Button::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\services\form\meta\inputs;
4
5
class Button
6
{
7
    /**
8
     * indicates that the HTML input type is 'button'
9
     */
10
    public const TYPE_BUTTON = 'button';
11
12
    /**
13
     * indicates that the HTML input type is 'reset'
14
     */
15
    public const TYPE_BUTTON_RESET = 'reset';
16
17
    /**
18
     * indicates that the HTML input type is 'submit'
19
     */
20
    public const TYPE_BUTTON_SUBMIT = 'submit';
21
22
23
    /**
24
     * @var array
25
     */
26
    private $valid_type_options;
27
28
29
    public function __construct()
30
    {
31
        $this->valid_type_options = apply_filters(
32
            'FHEE__EventEspresso_core_services_form_meta_inputs_Button__valid_type_options',
33
            [
34
                Button::TYPE_BUTTON        => esc_html__('Button', 'event_espresso'),
35
                Button::TYPE_BUTTON_RESET  => esc_html__('Reset Button', 'event_espresso'),
36
                Button::TYPE_BUTTON_SUBMIT => esc_html__('Submit Button', 'event_espresso'),
37
            ]
38
        );
39
    }
40
41
42
    /**
43
     * @param bool $constants_only
44
     * @return array
45
     */
46
    public function validTypeOptions(bool $constants_only = false): array
47
    {
48
        return $constants_only
49
            ? array_keys($this->valid_type_options)
50
            : $this->valid_type_options;
51
    }
52
}
53