Completed
Pull Request — develop (#1369)
by
unknown
03:28
created

Vocabulary_Loader::init_vocabulary()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 57

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 57
rs 8.9381
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
namespace Wordlift\Vocabulary;
4
5
use Wordlift\Api\Default_Api_Service;
6
use Wordlift\Api\User_Agent;
7
use Wordlift\Vocabulary\Api\Background_Analysis_Endpoint;
8
use Wordlift\Vocabulary\Api\Entity_Rest_Endpoint;
9
use Wordlift\Vocabulary\Api\Reconcile_Progress_Endpoint;
10
use Wordlift\Vocabulary\Api\Tag_Rest_Endpoint;
11
use Wordlift\Vocabulary\Cache\Cache_Service_Factory;
12
use Wordlift\Vocabulary\Dashboard\Term_Matches_Widget;
13
use Wordlift\Vocabulary\Data\Term_Count\Cached_Term_count_Manager;
14
use Wordlift\Vocabulary\Data\Term_Count\Term_Count_Factory;
15
use Wordlift\Vocabulary\Data\Term_Data\Term_Data_Factory;
16
use Wordlift\Vocabulary\Hooks\Tag_Created_Hook;
17
use Wordlift\Vocabulary\Hooks\Term_Page_Hook;
18
use Wordlift\Vocabulary\Jsonld\Post_Jsonld;
19
use Wordlift\Vocabulary\Jsonld\Term_Jsonld;
20
use Wordlift\Vocabulary\Pages\Match_Terms;
21
use Wordlift\Vocabulary\Tabs\Settings_Tab;
22
23
class Vocabulary_Loader {
24
25
	public function init_vocabulary() {
26
27
		$configuration_service = \Wordlift_Configuration_Service::get_instance();
28
29
		$api_service = new Default_Api_Service(
30
			apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
31
			60,
32
			User_Agent::get_user_agent(),
33
			$configuration_service->get_key()
34
		);
35
36
		$cache_service    = Cache_Service_Factory::get_cache_service();
37
38
39
		$analysis_service = new Analysis_Service( $api_service, $cache_service );
40
41
		$term_data_factory = new Term_Data_Factory( $analysis_service );
42
43
		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
44
		$tag_rest_endpoint->register_routes();
45
46
		$entity_rest_endpoint = new Entity_Rest_Endpoint();
47
		$entity_rest_endpoint->register_routes();
48
49
		$post_jsonld = new Post_Jsonld();
50
		$post_jsonld->enhance_post_jsonld();
51
52
		$term_jsonld = new Term_Jsonld();
53
		$term_jsonld->init();
54
55
		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
56
		new Match_Terms( $term_count );
57
58
		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
59
60
61
		new Tag_Created_Hook( $analysis_background_service );
62
63
		new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
64
65
		$reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
66
		$reconcile_progress_endpoint->register_routes();
67
68
69
		$term_page_hook = new Term_Page_Hook( $term_data_factory );
70
		$term_page_hook->connect_hook();
71
72
		$dashboard_widget = new Term_Matches_Widget( $term_count );
73
		$dashboard_widget->connect_hook();
74
75
		$cached_term_count_manager = new Cached_Term_count_Manager();
76
		$cached_term_count_manager->connect_hook();
77
78
		$settings_tab = new Settings_Tab();
79
		$settings_tab->connect_hook();
80
81
	}
82
83
}
84
85
86