Conditions | 9 |
Paths | 11 |
Total Lines | 66 |
Code Lines | 27 |
Lines | 10 |
Ratio | 15.15 % |
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 |
||
128 | if ( ! $sub_app ) { |
||
129 | return null; |
||
130 | } |
||
131 | |||
132 | if ( |
||
133 | empty( $this->did_init[ $slug ] ) |
||
134 | && ! self::$main->silent |
||
135 | && $this->should_do_registry_init( $sub_app ) |
||
136 | ) { |
||
137 | |||
138 | $this->did_init[ $slug ] = true; |
||
139 | |||
140 | /** |
||
141 | * Initialization of an app registry. |
||
142 | * |
||
143 | * The $var is the slug of the registry. |
||
144 | * |
||
145 | * @since 1.0.0 |
||
146 | * |
||
147 | * @param WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI |
||
148 | * $registry The registry object. |
||
149 | */ |
||
150 | do_action( "wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app ); |
||
151 | } |
||
152 | |||
153 | return $sub_app; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * Get the sub apps registry. |
||
158 | * |
||
159 | * @since 1.0.0 |
||
160 | * |
||
161 | * @return WordPoints_Class_Registry_Persistent The sub apps registry. |
||
162 | */ |
||
163 | public function sub_apps() { |
||
164 | return $this->sub_apps; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Check whether to call the init action for a registry sub-app. |
||
169 | * |
||
170 | * @since 1.0.0 |
||
171 | * |
||
172 | * @param object $registry The sub-app object. |
||
173 | * |
||
174 | * @return bool Whether to call the init action or not. |
||
175 | */ |
||
176 | protected function should_do_registry_init( $registry ) { |
||
177 | return ( |
||
178 | $registry instanceof WordPoints_Class_RegistryI |
||
179 | || $registry instanceof WordPoints_Class_Registry_ChildrenI |
||
180 | ); |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * Initialize this app. |
||
185 | * |
||
186 | * @since 1.0.0 |
||
187 | */ |
||
188 | protected function init() { |
||
189 | |||
190 | /** |
||
191 | * WordPoints app initialized. |
||
192 | * |
||
193 | * The dynamic portion of the action is the slug of the app being |
||
194 | * initialized. |
||
205 |