Completed
Branch dev (420f4e)
by
unknown
35:10 queued 25:32
created

EEM_Question_Option::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 71

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 71
rs 8.6327
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Question Group Model
5
 *
6
 * @package     Event Espresso
7
 * @subpackage  includes/models/
8
 * @author      Michael Nelson
9
 */
10
class EEM_Question_Option extends EEM_Soft_Delete_Base
11
{
12
13
    // private instance of the Attendee object
14
    protected static $_instance = null;
15
16
17
    protected function __construct($timezone = null)
18
    {
19
        $this->singular_item = esc_html__('Question Option', 'event_espresso');
20
        $this->plural_item   = esc_html__('Question Options', 'event_espresso');
21
22
        $this->_tables          = [
23
            'Question_Option' => new EE_Primary_Table('esp_question_option', 'QSO_ID'),
24
        ];
25
        $this->_fields          = [
26
            'Question_Option' => [
27
                'QSO_ID'      => new EE_Primary_Key_Int_Field(
28
                    'QSO_ID', esc_html__('Question Option ID', 'event_espresso')
29
                ),
30
                'QST_ID'      => new EE_Foreign_Key_Int_Field(
31
                    'QST_ID',
32
                    esc_html__('Question ID', 'event_espresso'),
33
                    false,
34
                    0,
35
                    'Question'
36
                ),
37
                'QSO_value'   => new EE_Plain_Text_Field(
38
                    'QSO_value',
39
                    esc_html__("Question Option Value", "event_espresso"),
40
                    false,
41
                    ''
42
                ),
43
                'QSO_desc'    => new EE_Post_Content_Field(
44
                    'QSO_desc',
45
                    esc_html__('Question Option Description', 'event_espresso'),
46
                    false,
47
                    ''
48
                ),
49
                'QSO_order'   => new EE_Integer_Field(
50
                    'QSO_order',
51
                    esc_html__('Question Option Order', 'event_espresso'),
52
                    false,
53
                    0
54
                ),
55
                'QSO_system'  => new EE_Plain_Text_Field(
56
                    'QSO_system',
57
                    esc_html__('Internal string ID for question option', 'event_espresso'),
58
                    true,
59
                    null
60
                ),
61
                'QSO_deleted' => new EE_Trashed_Flag_Field(
62
                    'QSO_deleted',
63
                    esc_html__('Flag indicating Option was trashed', 'event_espresso'),
64
                    false,
65
                    false
66
                ),
67
            ],
68
        ];
69
        $this->_model_relations = [
70
            'Question' => new EE_Belongs_To_Relation(),
71
        ];
72
73
        $this->_caps_slug              = 'questions';
74
        $this->_model_chain_to_wp_user = 'Question';
75
76
        // this model is generally available for reading
77
        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
78
            new EE_Restriction_Generator_Public();
79
        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
80
            new EE_Restriction_Generator_Reg_Form('QSO_system');
81
        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
82
            new EE_Restriction_Generator_Reg_Form('QSO_system');
83
        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
84
            new EE_Restriction_Generator_Reg_Form('QSO_system');
85
86
        parent::__construct($timezone);
87
    }
88
}
89