Completed
Push — develop ( 72a91d...14a321 )
by
unknown
04:09 queued 12s
created

Vocabulary_Loader::init_vocabulary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 54
rs 9.0036
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\Pages\Match_Terms;
20
use Wordlift\Vocabulary\Tabs\Settings_Tab;
21
22
class Vocabulary_Loader {
23
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 );
0 ignored issues
show
Documentation introduced by
$cache_service is of type object<Wordlift\Vocabulary\Cache\Options_Cache>, but the function expects a object<Wordlift\Vocabulary\Options_Cache>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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
79
}
80
81
82