| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| 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 |
||
| 24 | public function init_vocabulary() { |
||
| 25 | |||
| 26 | $configuration_service = \Wordlift_Configuration_Service::get_instance(); |
||
| 27 | |||
| 28 | $api_service = new Default_Api_Service( |
||
| 29 | apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ), |
||
| 30 | 60, |
||
| 31 | User_Agent::get_user_agent(), |
||
| 32 | $configuration_service->get_key() |
||
| 33 | ); |
||
| 34 | |||
| 35 | $cache_service = Cache_Service_Factory::get_cache_service(); |
||
| 36 | |||
| 37 | |||
| 38 | $analysis_service = new Analysis_Service( $api_service, $cache_service ); |
||
|
|
|||
| 39 | |||
| 40 | $term_data_factory = new Term_Data_Factory( $analysis_service ); |
||
| 41 | |||
| 42 | $tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory ); |
||
| 43 | $tag_rest_endpoint->register_routes(); |
||
| 44 | |||
| 45 | $entity_rest_endpoint = new Entity_Rest_Endpoint(); |
||
| 46 | $entity_rest_endpoint->register_routes(); |
||
| 47 | |||
| 48 | $post_jsonld = new Post_Jsonld(); |
||
| 49 | $post_jsonld->enhance_post_jsonld(); |
||
| 50 | |||
| 51 | $term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT ); |
||
| 52 | new Match_Terms( $term_count ); |
||
| 53 | |||
| 54 | $analysis_background_service = new Analysis_Background_Service( $analysis_service ); |
||
| 55 | |||
| 56 | |||
| 57 | new Tag_Created_Hook( $analysis_background_service ); |
||
| 58 | |||
| 59 | new Background_Analysis_Endpoint( $analysis_background_service, $cache_service ); |
||
| 60 | |||
| 61 | $reconcile_progress_endpoint = new Reconcile_Progress_Endpoint(); |
||
| 62 | $reconcile_progress_endpoint->register_routes(); |
||
| 63 | |||
| 64 | |||
| 65 | $term_page_hook = new Term_Page_Hook( $term_data_factory ); |
||
| 66 | $term_page_hook->connect_hook(); |
||
| 67 | |||
| 68 | $dashboard_widget = new Term_Matches_Widget( $term_count ); |
||
| 69 | $dashboard_widget->connect_hook(); |
||
| 70 | |||
| 71 | $cached_term_count_manager = new Cached_Term_count_Manager(); |
||
| 72 | $cached_term_count_manager->connect_hook(); |
||
| 73 | |||
| 74 | $settings_tab = new Settings_Tab(); |
||
| 75 | $settings_tab->connect_hook(); |
||
| 76 | |||
| 77 | } |
||
| 78 | |||
| 82 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: