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

Element   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A validStatusOptions() 0 6 2
1
<?php
2
3
namespace EventEspresso\core\services\form\meta;
4
5
class Element
6
{
7
8
    /**
9
     * indicates that element is not archived or trashed
10
     */
11
    public const STATUS_ACTIVE = 'active';
12
13
    /**
14
     * indicates that element is archived and should no longer be displayed on public forms
15
     * but may still be required due to existing answers when form was completed prior to input being archived
16
     */
17
    public const STATUS_ARCHIVED = 'archived';
18
19
    /**
20
     * indicates that element should be automatically added to newly created forms
21
     */
22
    public const STATUS_DEFAULT = 'default';
23
24
    /**
25
     * indicates that element is no longer needed, has no existing answers, and can be moved to the trash
26
     */
27
    public const STATUS_TRASHED = 'trashed';
28
29
    /**
30
     * @var array
31
     */
32
    private $valid_status_options;
33
34
35
    public function __construct()
36
    {
37
        $this->valid_status_options = apply_filters(
38
            'FHEE__EventEspresso_core_services_form_meta_Element__valid_status_options',
39
            [
40
                Element::STATUS_ACTIVE   => esc_html__('Active', 'event_espresso'),
41
                Element::STATUS_ARCHIVED => esc_html__('Archived', 'event_espresso'),
42
                Element::STATUS_DEFAULT  => esc_html__('Default', 'event_espresso'),
43
                Element::STATUS_TRASHED  => esc_html__('Trashed', 'event_espresso'),
44
            ]
45
        );
46
    }
47
48
49
    /**
50
     * @param bool $constants_only
51
     * @return array
52
     */
53
    public function validStatusOptions(bool $constants_only = false): array
54
    {
55
        return $constants_only
56
            ? array_keys($this->valid_status_options)
57
            : $this->valid_status_options;
58
    }
59
}
60