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

Number   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A validTypeOptions() 0 6 2
1
<?php
2
3
namespace EventEspresso\core\services\form\meta\inputs;
4
5
class Number
6
{
7
8
    /**
9
     * indicates that the HTML input type is 'number' whose value is a decimal (float)
10
     */
11
    public const TYPE_FLOAT = 'decimal';
12
13
    /**
14
     * indicates that the HTML input type is 'number' whose value is an integer (whole number)
15
     */
16
    public const TYPE_INT = 'integer';
17
18
    /**
19
     * indicates that the HTML input type is 'range'
20
     */
21
    public const TYPE_RANGE = 'range';
22
23
24
    /**
25
     * @var array
26
     */
27
    private $valid_type_options;
28
29
30
    public function __construct()
31
    {
32
        $this->valid_type_options = apply_filters(
33
            'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options',
34
            [
35
                Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'),
36
                Number::TYPE_INT   => esc_html__('Integer (Whole) Number', 'event_espresso'),
37
                Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'),
38
            ]
39
        );
40
    }
41
42
43
    /**
44
     * @param bool $constants_only
45
     * @return array
46
     */
47
    public function validTypeOptions(bool $constants_only = false): array
48
    {
49
        return $constants_only
50
            ? array_keys($this->valid_type_options)
51
            : $this->valid_type_options;
52
    }
53
}
54