Conditions | 1 |
Paths | 1 |
Total Lines | 103 |
Code Lines | 86 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
110 | protected function __construct( $timezone = NULL ) { |
||
111 | $this->singular_item = __('Question','event_espresso'); |
||
112 | $this->plural_item = __('Questions','event_espresso'); |
||
113 | $this->_allowed_question_types=apply_filters( |
||
114 | 'FHEE__EEM_Question__construct__allowed_question_types', |
||
115 | array( |
||
116 | EEM_Question::QST_type_text =>__('Text','event_espresso'), |
||
117 | EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'), |
||
118 | EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'), |
||
119 | EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'), |
||
120 | EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'), |
||
121 | EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'), |
||
122 | EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'), |
||
123 | EEM_Question::QST_type_date =>__('Date Picker','event_espresso'), |
||
124 | EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ), |
||
125 | EEM_Question::QST_type_email => __( 'Email', 'event_espresso' ), |
||
126 | EEM_Question::QST_type_us_phone => __( 'USA - Format Phone', 'event_espresso' ), |
||
127 | EEM_Question::QST_type_decimal => __( 'Number', 'event_espresso' ), |
||
128 | EEM_Question::QST_type_int => __( 'Whole Number', 'event_espresso' ), |
||
129 | EEM_Question::QST_type_url => __( 'URL', 'event_espresso' ), |
||
130 | EEM_Question::QST_type_year => __( 'Year', 'event_espresso' ), |
||
131 | EEM_Question::QST_type_multi_select => __( 'Multi Select', 'event_espresso' ) |
||
132 | ) |
||
133 | ); |
||
134 | $this->_question_descriptions = apply_filters( |
||
135 | 'FHEE__EEM_Question__construct__allowed_question_types', |
||
136 | array( |
||
137 | EEM_Question::QST_type_text => __( 'A single line text input field', 'event_espresso' ), |
||
138 | EEM_Question::QST_type_textarea => __( 'A multi line text input field', 'event_espresso' ), |
||
139 | EEM_Question::QST_type_checkbox => __( 'Allows multiple preset options to be selected', 'event_espresso' ), |
||
140 | EEM_Question::QST_type_radio => __( 'Allows a single preset option to be selected', 'event_espresso' ), |
||
141 | EEM_Question::QST_type_dropdown => __( 'A dropdown that allows a single selection', 'event_espresso' ), |
||
142 | EEM_Question::QST_type_state => __( 'A dropdown that lists states/provinces', 'event_espresso' ), |
||
143 | EEM_Question::QST_type_country => __( 'A dropdown that lists countries', 'event_espresso' ), |
||
144 | EEM_Question::QST_type_date => __( 'A popup calendar that allows date selections', 'event_espresso' ), |
||
145 | EEM_Question::QST_type_html_textarea => __( 'A multi line text input field that allows HTML', 'event_espresso' ), |
||
146 | EEM_Question::QST_type_email => __( 'A text field that must contain a valid Email address', 'event_espresso' ), |
||
147 | EEM_Question::QST_type_us_phone => __( 'A text field that must contain a valid US phone number', 'event_espresso' ), |
||
148 | EEM_Question::QST_type_decimal => __( 'A text field that allows number values with decimals', 'event_espresso' ), |
||
149 | EEM_Question::QST_type_int => __( 'A text field that only allows whole numbers (no decimals)', 'event_espresso' ), |
||
150 | EEM_Question::QST_type_url => __( 'A text field that must contain a valid URL', 'event_espresso' ), |
||
151 | EEM_Question::QST_type_year => __( 'A dropdown that lists the last 100 years', 'event_espresso' ), |
||
152 | EEM_Question::QST_type_multi_select => __( 'A dropdown that allows multiple selections', 'event_espresso' ) |
||
153 | ) |
||
154 | ); |
||
155 | $this->_question_type_categories = apply_filters( |
||
156 | 'FHEE__EEM_Question__construct__question_type_categories', |
||
157 | array( |
||
158 | 'text' => array( |
||
159 | EEM_Question::QST_type_text, |
||
160 | EEM_Question::QST_type_textarea, |
||
161 | EEM_Question::QST_type_html_textarea, |
||
162 | EEM_Question::QST_type_email, |
||
163 | EEM_Question::QST_type_us_phone, |
||
164 | EEM_Question::QST_type_int, |
||
165 | EEM_Question::QST_type_decimal, |
||
166 | EEM_Question::QST_type_url, |
||
167 | ), |
||
168 | 'single-answer-enum' => array( |
||
169 | EEM_Question::QST_type_radio, |
||
170 | EEM_Question::QST_type_dropdown |
||
171 | ), |
||
172 | 'multi-answer-enum' => array( |
||
173 | EEM_Question::QST_type_checkbox, |
||
174 | EEM_Question::QST_type_multi_select |
||
175 | ) |
||
176 | ) |
||
177 | ); |
||
178 | |||
179 | $this->_tables = array( |
||
|
|||
180 | 'Question'=>new EE_Primary_Table('esp_question','QST_ID') |
||
181 | ); |
||
182 | $this->_fields = array( |
||
183 | 'Question'=>array( |
||
184 | 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')), |
||
185 | 'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''), |
||
186 | 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''), |
||
187 | 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ), |
||
188 | 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types), |
||
189 | 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false), |
||
190 | 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''), |
||
191 | 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0), |
||
192 | 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false), |
||
193 | 'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso' ), false, EE_INF ), |
||
194 | 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ), |
||
195 | 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false) |
||
196 | ) |
||
197 | ); |
||
198 | $this->_model_relations = array( |
||
199 | 'Question_Group'=>new EE_HABTM_Relation('Question_Group_Question'), |
||
200 | 'Question_Option'=>new EE_Has_Many_Relation(), |
||
201 | 'Answer'=>new EE_Has_Many_Relation(), |
||
202 | 'WP_User' => new EE_Belongs_To_Relation(), |
||
203 | //for QST_order column |
||
204 | 'Question_Group_Question'=>new EE_Has_Many_Relation() |
||
205 | ); |
||
206 | //this model is generally available for reading |
||
207 | $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
||
208 | $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
||
209 | $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
||
210 | $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
||
211 | parent::__construct( $timezone ); |
||
212 | } |
||
213 | |||
391 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..