Completed
Branch FET/reg-form-builder/main (a66e69)
by
unknown
09:49 queued 19s
created

Text   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A validTypeOptions() 0 6 2
1
<?php
2
3
namespace EventEspresso\core\services\form\meta\inputs;
4
5
class Text
6
{
7
    /**
8
     * indicates that the HTML input type is 'email'
9
     */
10
    public const TYPE_EMAIL = 'email';
11
12
    /**
13
     * indicates that the input is used to confirm an email address
14
     */
15
    public const TYPE_EMAIL_CONFIRM = 'email-confirmation';
16
17
    /**
18
     * indicates that the HTML input type is 'text'
19
     */
20
    public const TYPE_TEXT = 'text';
21
22
    /**
23
     * indicates that the input is a TEXTAREA that only allows plain text
24
     */
25
    public const TYPE_TEXTAREA = 'textarea';
26
27
    /**
28
     * indicates that the input is a TEXTAREA that allows simple html
29
     */
30
    public const TYPE_TEXTAREA_HTML = 'textarea-html';
31
32
33
    /**
34
     * @var array
35
     */
36
    private $valid_type_options;
37
38
39
    public function __construct()
40
    {
41
        $this->valid_type_options = apply_filters(
42
            'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options',
43
            [
44
                Text::TYPE_EMAIL         => esc_html__('Email', 'event_espresso'),
45
                Text::TYPE_EMAIL_CONFIRM => esc_html__('Email Confirmation', 'event_espresso'),
46
                Text::TYPE_TEXT          => esc_html__('Plain Text', 'event_espresso'),
47
                Text::TYPE_TEXTAREA      => esc_html__('Plain Textarea', 'event_espresso'),
48
                Text::TYPE_TEXTAREA_HTML => esc_html__('Simple HTML Textarea', 'event_espresso'),
49
            ]
50
        );
51
    }
52
53
54
    /**
55
     * @param bool $constants_only
56
     * @return array
57
     */
58
    public function validTypeOptions(bool $constants_only = false): array
59
    {
60
        return $constants_only
61
            ? array_keys($this->valid_type_options)
62
            : $this->valid_type_options;
63
    }
64
}
65