| Conditions | 1 |
| Paths | 1 |
| Total Lines | 94 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 30 | protected function __construct($timezone = null) |
||
| 31 | { |
||
| 32 | $this->singular_item = esc_html__('Question Group', 'event_espresso'); |
||
| 33 | $this->plural_item = esc_html__('Question Groups', 'event_espresso'); |
||
| 34 | |||
| 35 | $this->_tables = [ |
||
| 36 | 'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID'), |
||
| 37 | ]; |
||
| 38 | $this->_fields = [ |
||
| 39 | 'Question_Group' => [ |
||
| 40 | 'QSG_ID' => new EE_Primary_Key_Int_Field( |
||
| 41 | 'QSG_ID', |
||
| 42 | esc_html__('Question Group ID', 'event_espresso') |
||
| 43 | ), |
||
| 44 | 'QSG_name' => new EE_Plain_Text_Field( |
||
| 45 | 'QSG_name', |
||
| 46 | esc_html__('Question Group Name', 'event_espresso'), |
||
| 47 | false, |
||
| 48 | '' |
||
| 49 | ), |
||
| 50 | 'QSG_identifier' => new EE_Plain_Text_Field( |
||
| 51 | 'QSG_identifier', |
||
| 52 | esc_html__('Text ID for question Group', 'event_espresso'), |
||
| 53 | false, |
||
| 54 | '' |
||
| 55 | ), |
||
| 56 | 'QSG_desc' => new EE_Post_Content_Field( |
||
| 57 | 'QSG_desc', |
||
| 58 | esc_html__('Description of Question Group', 'event_espresso'), |
||
| 59 | true, |
||
| 60 | '' |
||
| 61 | ), |
||
| 62 | 'QSG_order' => new EE_Integer_Field( |
||
| 63 | 'QSG_order', |
||
| 64 | esc_html__('Order in which to show the question group', 'event_espresso'), |
||
| 65 | true, |
||
| 66 | 0 |
||
| 67 | ), |
||
| 68 | 'QSG_show_group_name' => new EE_Boolean_Field( |
||
| 69 | 'QSG_show_group_name', |
||
| 70 | esc_html__( |
||
| 71 | 'Flag indicating whether to show the group\'s name on the registration page', |
||
| 72 | 'event_espresso' |
||
| 73 | ), |
||
| 74 | false, |
||
| 75 | true |
||
| 76 | ), |
||
| 77 | 'QSG_show_group_desc' => new EE_Boolean_Field( |
||
| 78 | 'QSG_show_group_desc', |
||
| 79 | esc_html__( |
||
| 80 | 'Flag indicating whether to show the group\s description on the registration page', |
||
| 81 | 'event_espresso' |
||
| 82 | ), false, |
||
| 83 | false |
||
| 84 | ), |
||
| 85 | 'QSG_wp_user' => new EE_WP_User_Field( |
||
| 86 | 'QSG_wp_user', |
||
| 87 | esc_html__('Question Group Creator ID', 'event_espresso'), |
||
| 88 | false |
||
| 89 | ), |
||
| 90 | 'QSG_system' => new EE_Integer_Field( |
||
| 91 | 'QSG_system', |
||
| 92 | esc_html__( |
||
| 93 | 'Indicate IF this is a system group and if it is what system group it corresponds to.', |
||
| 94 | 'event_espresso' |
||
| 95 | ), false, |
||
| 96 | 0 |
||
| 97 | ), |
||
| 98 | 'QSG_deleted' => new EE_Trashed_Flag_Field( |
||
| 99 | 'QSG_deleted', |
||
| 100 | esc_html__('Flag indicating this question group was deleted', 'event_espresso'), |
||
| 101 | false, |
||
| 102 | false |
||
| 103 | ), |
||
| 104 | ], |
||
| 105 | ]; |
||
| 106 | $this->_model_relations = [ |
||
| 107 | 'Question' => new EE_HABTM_Relation('Question_Group_Question'), |
||
| 108 | 'Event' => new EE_HABTM_Relation('Event_Question_Group'), |
||
| 109 | 'Event_Question_Group' => new EE_Has_Many_Relation(), |
||
| 110 | 'WP_User' => new EE_Belongs_To_Relation(), |
||
| 111 | ]; |
||
| 112 | // this model is generally available for reading |
||
| 113 | $this->_cap_restriction_generators[ EEM_Base::caps_read ] = |
||
| 114 | new EE_Restriction_Generator_Public(); |
||
| 115 | $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
||
| 116 | new EE_Restriction_Generator_Reg_Form('QSG_system'); |
||
| 117 | $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = |
||
| 118 | new EE_Restriction_Generator_Reg_Form('QSG_system'); |
||
| 119 | $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
||
| 120 | new EE_Restriction_Generator_Reg_Form('QSG_system'); |
||
| 121 | |||
| 122 | parent::__construct($timezone); |
||
| 123 | } |
||
| 124 | |||
| 144 |