Completed
Pull Request — master (#1465)
by Naveen
57s
created
src/modules/analyzer/wordlift_analyzer.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
  * @since 3.27.6
12 12
  */
13 13
 function wl_ajax_analyze_disabled_action() {
14
-	// adding the below header for debugging purpose.
15
-	if ( ! headers_sent() ) {
16
-		header( 'X-WordLift-Analysis: OFF' );
17
-	}
18
-	wp_send_json_success(
19
-		array(
20
-			'entities'    => array(),
21
-			'annotations' => array(),
22
-			'topics'      => array(),
23
-		)
24
-	);
14
+    // adding the below header for debugging purpose.
15
+    if ( ! headers_sent() ) {
16
+        header( 'X-WordLift-Analysis: OFF' );
17
+    }
18
+    wp_send_json_success(
19
+        array(
20
+            'entities'    => array(),
21
+            'annotations' => array(),
22
+            'topics'      => array(),
23
+        )
24
+    );
25 25
 }
26 26
 
27 27
 /**
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function wl_ajax_analyze_action() {
37 37
 
38
-	check_admin_referer( 'wl_analyze' );
38
+    check_admin_referer( 'wl_analyze' );
39 39
 
40
-	// If you use `filter_input` here, `Ajax_Content_Analysis_Test` would fail because `filter_input` doesn't use
41
-	// `$_POST`.
42
-	$data = $_POST['data'];
40
+    // If you use `filter_input` here, `Ajax_Content_Analysis_Test` would fail because `filter_input` doesn't use
41
+    // `$_POST`.
42
+    $data = $_POST['data'];
43 43
 
44
-	wp_send_json_success( wl_analyze_content( $data, 'application/json; charset=' . strtolower( get_bloginfo( 'charset' ) ) ) );
44
+    wp_send_json_success( wl_analyze_content( $data, 'application/json; charset=' . strtolower( get_bloginfo( 'charset' ) ) ) );
45 45
 
46 46
 }
47 47
 
@@ -63,74 +63,74 @@  discard block
 block discarded – undo
63 63
  */
64 64
 function wl_analyze_content( $data, $content_type ) {
65 65
 
66
-	$default_response = json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' );
67
-	$request_body     = json_decode( $data, true );
68
-	$post_id = isset( $_REQUEST['postId'] ) ? intval( $_REQUEST['postId'] ) : 0;
69
-	if ( $request_body === null ) {
70
-		/**
71
-		 * @since 3.27.7
72
-		 *
73
-		 * Conditionally try using stripslashes as $_POST['data'] could be escaped
74
-		 */
75
-		$request_body = json_decode( stripslashes( $data ), true );
76
-	}
77
-	$request_body['contentLanguage'] = Wordlift_Configuration_Service::get_instance()->get_language_code();
78
-	$excluded_uris                   = array_key_exists( 'exclude', $request_body ) ? (array) $request_body['exclude'] : array();
79
-	$data                            = wp_json_encode( $request_body );
80
-
81
-	// If dataset is not enabled, return a locally prepared response without analysis API.
82
-	if ( ! apply_filters( 'wl_features__enable__dataset', true ) ) {
83
-
84
-		return Analysis_Response_Ops_Factory::get_instance()
85
-											->create( $default_response, $post_id )
86
-											->make_entities_local()
87
-											->add_occurrences( $request_body['content'] )
88
-											->add_local_entities()
89
-											->get_json();
90
-	}
91
-
92
-	add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
93
-
94
-
95
-	$json    = Analysis_Service_Factory::get_instance( $post_id )
96
-								->get_analysis_response( $data, $content_type, $post_id );
97
-
98
-	remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
99
-
100
-	// If it's an error log it.
101
-	if ( is_wp_error( $json ) ) {
102
-		return Analysis_Response_Ops_Factory::get_instance()
103
-											->create( $default_response, $post_id )
104
-											->make_entities_local()
105
-											->add_occurrences( $request_body['content'] )
106
-											->get_json();
107
-	}
108
-
109
-	/*
66
+    $default_response = json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' );
67
+    $request_body     = json_decode( $data, true );
68
+    $post_id = isset( $_REQUEST['postId'] ) ? intval( $_REQUEST['postId'] ) : 0;
69
+    if ( $request_body === null ) {
70
+        /**
71
+         * @since 3.27.7
72
+         *
73
+         * Conditionally try using stripslashes as $_POST['data'] could be escaped
74
+         */
75
+        $request_body = json_decode( stripslashes( $data ), true );
76
+    }
77
+    $request_body['contentLanguage'] = Wordlift_Configuration_Service::get_instance()->get_language_code();
78
+    $excluded_uris                   = array_key_exists( 'exclude', $request_body ) ? (array) $request_body['exclude'] : array();
79
+    $data                            = wp_json_encode( $request_body );
80
+
81
+    // If dataset is not enabled, return a locally prepared response without analysis API.
82
+    if ( ! apply_filters( 'wl_features__enable__dataset', true ) ) {
83
+
84
+        return Analysis_Response_Ops_Factory::get_instance()
85
+                                            ->create( $default_response, $post_id )
86
+                                            ->make_entities_local()
87
+                                            ->add_occurrences( $request_body['content'] )
88
+                                            ->add_local_entities()
89
+                                            ->get_json();
90
+    }
91
+
92
+    add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
93
+
94
+
95
+    $json    = Analysis_Service_Factory::get_instance( $post_id )
96
+                                ->get_analysis_response( $data, $content_type, $post_id );
97
+
98
+    remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
99
+
100
+    // If it's an error log it.
101
+    if ( is_wp_error( $json ) ) {
102
+        return Analysis_Response_Ops_Factory::get_instance()
103
+                                            ->create( $default_response, $post_id )
104
+                                            ->make_entities_local()
105
+                                            ->add_occurrences( $request_body['content'] )
106
+                                            ->get_json();
107
+    }
108
+
109
+    /*
110 110
 	 * We pass the response to the Analysis_Response_Ops to ensure that we make remote entities local.
111 111
 	 *
112 112
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/944
113 113
 	 * @since 3.21.5
114 114
 	 */
115 115
 
116
-	// Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate
117
-	// the occurrences for the local entities.
118
-	if ( 0 === strpos( $content_type, 'application/json' ) ) {
119
-		$request_content = $request_body['content'];
120
-	} else {
121
-		$request_content = $data;
122
-	}
123
-
124
-	return Analysis_Response_Ops_Factory::get_instance()
125
-										->create( $json, $post_id )
126
-										->make_entities_local()
127
-										->remove_excluded_entities( $excluded_uris )
128
-										->add_occurrences( $request_content )
129
-										->get_json();
116
+    // Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate
117
+    // the occurrences for the local entities.
118
+    if ( 0 === strpos( $content_type, 'application/json' ) ) {
119
+        $request_content = $request_body['content'];
120
+    } else {
121
+        $request_content = $data;
122
+    }
123
+
124
+    return Analysis_Response_Ops_Factory::get_instance()
125
+                                        ->create( $json, $post_id )
126
+                                        ->make_entities_local()
127
+                                        ->remove_excluded_entities( $excluded_uris )
128
+                                        ->add_occurrences( $request_content )
129
+                                        ->get_json();
130 130
 
131 131
 }
132 132
 
133 133
 function wl_use_analysis_on_api_wordlift_io( $value ) {
134 134
 
135
-	return preg_replace( '|https://api\.wordlift\.it/|', apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ) . '/', $value );
135
+    return preg_replace( '|https://api\.wordlift\.it/|', apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ) . '/', $value );
136 136
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  */
13 13
 function wl_ajax_analyze_disabled_action() {
14 14
 	// adding the below header for debugging purpose.
15
-	if ( ! headers_sent() ) {
16
-		header( 'X-WordLift-Analysis: OFF' );
15
+	if ( ! headers_sent()) {
16
+		header('X-WordLift-Analysis: OFF');
17 17
 	}
18 18
 	wp_send_json_success(
19 19
 		array(
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function wl_ajax_analyze_action() {
37 37
 
38
-	check_admin_referer( 'wl_analyze' );
38
+	check_admin_referer('wl_analyze');
39 39
 
40 40
 	// If you use `filter_input` here, `Ajax_Content_Analysis_Test` would fail because `filter_input` doesn't use
41 41
 	// `$_POST`.
42 42
 	$data = $_POST['data'];
43 43
 
44
-	wp_send_json_success( wl_analyze_content( $data, 'application/json; charset=' . strtolower( get_bloginfo( 'charset' ) ) ) );
44
+	wp_send_json_success(wl_analyze_content($data, 'application/json; charset='.strtolower(get_bloginfo('charset'))));
45 45
 
46 46
 }
47 47
 
@@ -61,48 +61,48 @@  discard block
 block discarded – undo
61 61
  * @since 3.24.2 We don't return an error anymore, but an empty analysis response. This is required to allow the editor
62 62
  *   to manage entities or to manually add them even when analysis isn't available.
63 63
  */
64
-function wl_analyze_content( $data, $content_type ) {
64
+function wl_analyze_content($data, $content_type) {
65 65
 
66
-	$default_response = json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' );
67
-	$request_body     = json_decode( $data, true );
68
-	$post_id = isset( $_REQUEST['postId'] ) ? intval( $_REQUEST['postId'] ) : 0;
69
-	if ( $request_body === null ) {
66
+	$default_response = json_decode('{ "entities": {}, "annotations": {}, "topics": {} }');
67
+	$request_body     = json_decode($data, true);
68
+	$post_id = isset($_REQUEST['postId']) ? intval($_REQUEST['postId']) : 0;
69
+	if ($request_body === null) {
70 70
 		/**
71 71
 		 * @since 3.27.7
72 72
 		 *
73 73
 		 * Conditionally try using stripslashes as $_POST['data'] could be escaped
74 74
 		 */
75
-		$request_body = json_decode( stripslashes( $data ), true );
75
+		$request_body = json_decode(stripslashes($data), true);
76 76
 	}
77 77
 	$request_body['contentLanguage'] = Wordlift_Configuration_Service::get_instance()->get_language_code();
78
-	$excluded_uris                   = array_key_exists( 'exclude', $request_body ) ? (array) $request_body['exclude'] : array();
79
-	$data                            = wp_json_encode( $request_body );
78
+	$excluded_uris                   = array_key_exists('exclude', $request_body) ? (array) $request_body['exclude'] : array();
79
+	$data                            = wp_json_encode($request_body);
80 80
 
81 81
 	// If dataset is not enabled, return a locally prepared response without analysis API.
82
-	if ( ! apply_filters( 'wl_features__enable__dataset', true ) ) {
82
+	if ( ! apply_filters('wl_features__enable__dataset', true)) {
83 83
 
84 84
 		return Analysis_Response_Ops_Factory::get_instance()
85
-											->create( $default_response, $post_id )
85
+											->create($default_response, $post_id)
86 86
 											->make_entities_local()
87
-											->add_occurrences( $request_body['content'] )
87
+											->add_occurrences($request_body['content'])
88 88
 											->add_local_entities()
89 89
 											->get_json();
90 90
 	}
91 91
 
92
-	add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
92
+	add_filter('wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io');
93 93
 
94 94
 
95
-	$json    = Analysis_Service_Factory::get_instance( $post_id )
96
-								->get_analysis_response( $data, $content_type, $post_id );
95
+	$json = Analysis_Service_Factory::get_instance($post_id)
96
+								->get_analysis_response($data, $content_type, $post_id);
97 97
 
98
-	remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
98
+	remove_filter('wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io');
99 99
 
100 100
 	// If it's an error log it.
101
-	if ( is_wp_error( $json ) ) {
101
+	if (is_wp_error($json)) {
102 102
 		return Analysis_Response_Ops_Factory::get_instance()
103
-											->create( $default_response, $post_id )
103
+											->create($default_response, $post_id)
104 104
 											->make_entities_local()
105
-											->add_occurrences( $request_body['content'] )
105
+											->add_occurrences($request_body['content'])
106 106
 											->get_json();
107 107
 	}
108 108
 
@@ -115,22 +115,22 @@  discard block
 block discarded – undo
115 115
 
116 116
 	// Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate
117 117
 	// the occurrences for the local entities.
118
-	if ( 0 === strpos( $content_type, 'application/json' ) ) {
118
+	if (0 === strpos($content_type, 'application/json')) {
119 119
 		$request_content = $request_body['content'];
120 120
 	} else {
121 121
 		$request_content = $data;
122 122
 	}
123 123
 
124 124
 	return Analysis_Response_Ops_Factory::get_instance()
125
-										->create( $json, $post_id )
125
+										->create($json, $post_id)
126 126
 										->make_entities_local()
127
-										->remove_excluded_entities( $excluded_uris )
128
-										->add_occurrences( $request_content )
127
+										->remove_excluded_entities($excluded_uris)
128
+										->add_occurrences($request_content)
129 129
 										->get_json();
130 130
 
131 131
 }
132 132
 
133
-function wl_use_analysis_on_api_wordlift_io( $value ) {
133
+function wl_use_analysis_on_api_wordlift_io($value) {
134 134
 
135
-	return preg_replace( '|https://api\.wordlift\.it/|', apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ) . '/', $value );
135
+	return preg_replace('|https://api\.wordlift\.it/|', apply_filters('wl_api_base_url', 'https://api.wordlift.io').'/', $value);
136 136
 }
Please login to merge, or discard this patch.
src/wordlift/relation/class-object-relation-factory.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,20 +16,20 @@
 block discarded – undo
16 16
 
17 17
 class Object_Relation_Factory {
18 18
 
19
-	/**
20
-	 * @param int $post_id
21
-	 *
22
-	 * @return Relation_Service_Interface
23
-	 */
24
-	public static function get_instance( $post_id ) {
25
-		// The post type doesnt have an editor and no-editor-analysis feature is turned on.
26
-		if ( No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id ) ) {
27
-			return Object_No_Annotation_Relation_Service::get_instance();
28
-		}
29
-
30
-		return Object_Relation_Service::get_instance();
31
-
32
-	}
19
+    /**
20
+     * @param int $post_id
21
+     *
22
+     * @return Relation_Service_Interface
23
+     */
24
+    public static function get_instance( $post_id ) {
25
+        // The post type doesnt have an editor and no-editor-analysis feature is turned on.
26
+        if ( No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id ) ) {
27
+            return Object_No_Annotation_Relation_Service::get_instance();
28
+        }
29
+
30
+        return Object_Relation_Service::get_instance();
31
+
32
+    }
33 33
 
34 34
 
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@
 block discarded – undo
21 21
 	 *
22 22
 	 * @return Relation_Service_Interface
23 23
 	 */
24
-	public static function get_instance( $post_id ) {
24
+	public static function get_instance($post_id) {
25 25
 		// The post type doesnt have an editor and no-editor-analysis feature is turned on.
26
-		if ( No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id ) ) {
26
+		if (No_Editor_Analysis_Feature::can_no_editor_analysis_be_used($post_id)) {
27 27
 			return Object_No_Annotation_Relation_Service::get_instance();
28 28
 		}
29 29
 
Please login to merge, or discard this patch.
src/wordlift/relation/class-object-relation-service.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -18,80 +18,80 @@
 block discarded – undo
18 18
 
19 19
 class Object_Relation_Service extends Singleton implements Relation_Service_Interface {
20 20
 
21
-	/**
22
-	 * @var \Wordlift_Relation_Service
23
-	 */
24
-	protected $post_relation_service;
25
-	/**
26
-	 * @var Term_Relation_Service
27
-	 */
28
-	protected $term_relation_service;
29
-
30
-	/**
31
-	 * @var \Wordlift_Log_Service
32
-	 */
33
-	private $log;
34
-
35
-	public function __construct() {
36
-		parent::__construct();
37
-		$this->post_relation_service = Post_Relation_Service::get_instance();
38
-		$this->term_relation_service = Term_Relation_Service::get_instance();
39
-		$this->log                   = \Wordlift_Log_Service::get_logger( get_class() );
40
-	}
41
-
42
-	/**
43
-	 * @return Object_Relation_Service
44
-	 */
45
-	public static function get_instance() {
46
-		return parent::get_instance();
47
-	}
48
-
49
-	/**
50
-	 * @param $subject_id int
51
-	 *
52
-	 * @return array<Reference>
53
-	 */
54
-	public function get_references( $subject_id, $subject_type ) {
55
-		$post_references = $this->post_relation_service->get_references( $subject_id, $subject_type );
56
-		$term_references = $this->term_relation_service->get_references( $subject_id, $subject_type );
57
-
58
-		/**
59
-		 * @since 3.31.3
60
-		 * Should return only unique references.
61
-		 */
62
-		return array_unique( array_merge( $post_references, $term_references ) );
63
-	}
64
-
65
-
66
-	public function get_relations_from_content( $content, $subject_type ) {
67
-		$post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type );
68
-		$term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type );
69
-		return array_filter( array_merge( $post_relations, $term_relations) );
70
-	}
71
-
72
-
73
-	public static function get_entity_uris( $content ) {
74
-		// Remove quote escapes.
75
-		$content = str_replace( '\\"', '"', $content );
76
-
77
-		// Match all itemid attributes.
78
-		$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
79
-
80
-		// Remove the pattern while it is found (match nested annotations).
81
-		$matches = array();
82
-
83
-		// In case of errors, return an empty array.
84
-		if ( false === preg_match_all( $pattern, $content, $matches ) ) {
85
-
86
-			return array();
87
-		}
88
-
89
-		return $matches[1];
90
-	}
91
-
92
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
93
-		$post_relations = $this->post_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris );
94
-		$term_relations = $this->term_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris );
95
-		return array_filter( array_merge( $post_relations, $term_relations) );
96
-	}
21
+    /**
22
+     * @var \Wordlift_Relation_Service
23
+     */
24
+    protected $post_relation_service;
25
+    /**
26
+     * @var Term_Relation_Service
27
+     */
28
+    protected $term_relation_service;
29
+
30
+    /**
31
+     * @var \Wordlift_Log_Service
32
+     */
33
+    private $log;
34
+
35
+    public function __construct() {
36
+        parent::__construct();
37
+        $this->post_relation_service = Post_Relation_Service::get_instance();
38
+        $this->term_relation_service = Term_Relation_Service::get_instance();
39
+        $this->log                   = \Wordlift_Log_Service::get_logger( get_class() );
40
+    }
41
+
42
+    /**
43
+     * @return Object_Relation_Service
44
+     */
45
+    public static function get_instance() {
46
+        return parent::get_instance();
47
+    }
48
+
49
+    /**
50
+     * @param $subject_id int
51
+     *
52
+     * @return array<Reference>
53
+     */
54
+    public function get_references( $subject_id, $subject_type ) {
55
+        $post_references = $this->post_relation_service->get_references( $subject_id, $subject_type );
56
+        $term_references = $this->term_relation_service->get_references( $subject_id, $subject_type );
57
+
58
+        /**
59
+         * @since 3.31.3
60
+         * Should return only unique references.
61
+         */
62
+        return array_unique( array_merge( $post_references, $term_references ) );
63
+    }
64
+
65
+
66
+    public function get_relations_from_content( $content, $subject_type ) {
67
+        $post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type );
68
+        $term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type );
69
+        return array_filter( array_merge( $post_relations, $term_relations) );
70
+    }
71
+
72
+
73
+    public static function get_entity_uris( $content ) {
74
+        // Remove quote escapes.
75
+        $content = str_replace( '\\"', '"', $content );
76
+
77
+        // Match all itemid attributes.
78
+        $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
79
+
80
+        // Remove the pattern while it is found (match nested annotations).
81
+        $matches = array();
82
+
83
+        // In case of errors, return an empty array.
84
+        if ( false === preg_match_all( $pattern, $content, $matches ) ) {
85
+
86
+            return array();
87
+        }
88
+
89
+        return $matches[1];
90
+    }
91
+
92
+    public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
93
+        $post_relations = $this->post_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris );
94
+        $term_relations = $this->term_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris );
95
+        return array_filter( array_merge( $post_relations, $term_relations) );
96
+    }
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		parent::__construct();
37 37
 		$this->post_relation_service = Post_Relation_Service::get_instance();
38 38
 		$this->term_relation_service = Term_Relation_Service::get_instance();
39
-		$this->log                   = \Wordlift_Log_Service::get_logger( get_class() );
39
+		$this->log                   = \Wordlift_Log_Service::get_logger(get_class());
40 40
 	}
41 41
 
42 42
 	/**
@@ -51,28 +51,28 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @return array<Reference>
53 53
 	 */
54
-	public function get_references( $subject_id, $subject_type ) {
55
-		$post_references = $this->post_relation_service->get_references( $subject_id, $subject_type );
56
-		$term_references = $this->term_relation_service->get_references( $subject_id, $subject_type );
54
+	public function get_references($subject_id, $subject_type) {
55
+		$post_references = $this->post_relation_service->get_references($subject_id, $subject_type);
56
+		$term_references = $this->term_relation_service->get_references($subject_id, $subject_type);
57 57
 
58 58
 		/**
59 59
 		 * @since 3.31.3
60 60
 		 * Should return only unique references.
61 61
 		 */
62
-		return array_unique( array_merge( $post_references, $term_references ) );
62
+		return array_unique(array_merge($post_references, $term_references));
63 63
 	}
64 64
 
65 65
 
66
-	public function get_relations_from_content( $content, $subject_type ) {
67
-		$post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type );
68
-		$term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type );
69
-		return array_filter( array_merge( $post_relations, $term_relations) );
66
+	public function get_relations_from_content($content, $subject_type) {
67
+		$post_relations = $this->post_relation_service->get_relations_from_content($content, $subject_type);
68
+		$term_relations = $this->term_relation_service->get_relations_from_content($content, $subject_type);
69
+		return array_filter(array_merge($post_relations, $term_relations));
70 70
 	}
71 71
 
72 72
 
73
-	public static function get_entity_uris( $content ) {
73
+	public static function get_entity_uris($content) {
74 74
 		// Remove quote escapes.
75
-		$content = str_replace( '\\"', '"', $content );
75
+		$content = str_replace('\\"', '"', $content);
76 76
 
77 77
 		// Match all itemid attributes.
78 78
 		$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$matches = array();
82 82
 
83 83
 		// In case of errors, return an empty array.
84
-		if ( false === preg_match_all( $pattern, $content, $matches ) ) {
84
+		if (false === preg_match_all($pattern, $content, $matches)) {
85 85
 
86 86
 			return array();
87 87
 		}
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 		return $matches[1];
90 90
 	}
91 91
 
92
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
93
-		$post_relations = $this->post_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris );
94
-		$term_relations = $this->term_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris );
95
-		return array_filter( array_merge( $post_relations, $term_relations) );
92
+	public function get_relations_from_entity_uris($subject_type, $entity_uris) {
93
+		$post_relations = $this->post_relation_service->get_relations_from_entity_uris($subject_type, $entity_uris);
94
+		$term_relations = $this->term_relation_service->get_relations_from_entity_uris($subject_type, $entity_uris);
95
+		return array_filter(array_merge($post_relations, $term_relations));
96 96
 	}
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/relation/class-term-relation-service.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -21,89 +21,89 @@
 block discarded – undo
21 21
 
22 22
 class Term_Relation_Service extends Singleton implements Relation_Service_Interface {
23 23
 
24
-	/**
25
-	 * @var Uri_Service
26
-	 */
27
-	private $term_uri_service;
28
-	/**
29
-	 * @var Type_Service
30
-	 */
31
-	private $term_entity_type_service;
32
-
33
-
34
-	public function __construct() {
35
-		parent::__construct();
36
-		$this->term_uri_service         = Uri_Service::get_instance();
37
-		$this->term_entity_type_service = Type_Service::get_instance();
38
-	}
39
-
40
-	/**
41
-	 * @return Term_Relation_Service
42
-	 */
43
-	public static function get_instance() {
44
-		return parent::get_instance();
45
-	}
46
-
47
-
48
-	public function get_references( $subject_id, $subject_type ) {
49
-		global $wpdb;
50
-		$table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
51
-		$query      = $wpdb->prepare( "SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d",
52
-			$subject_id,
53
-			Object_Type_Enum::TERM,
54
-			$subject_type
55
-		);
56
-
57
-		$term_ids   = $wpdb->get_col( $query );
58
-
59
-		return array_map( function ( $term_id ) {
60
-			return new Term_Reference( $term_id );
61
-		}, $term_ids );
62
-	}
63
-
64
-
65
-	public function get_relations_from_content( $content, $subject_type ) {
66
-		$entity_uris = Object_Relation_Service::get_entity_uris( $content );
67
-		return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
68
-	}
69
-
70
-	/**
71
-	 * @param $term_id int Term id.
72
-	 */
73
-	public function get_relation_type( $term_id ) {
74
-		$schema               = $this->term_entity_type_service->get_schema(
75
-			$term_id
76
-		);
77
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
78
-
79
-		$entity_type = str_replace( 'wl-', '', $schema['css_class'] );
80
-		foreach ( $classification_boxes as $cb ) {
81
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
82
-				return $cb['id'];
83
-			}
84
-		}
85
-
86
-		return WL_WHAT_RELATION;
87
-	}
88
-
89
-	/**
90
-	 * @param $subject_type
91
-	 * @param $entity_uris
92
-	 *
93
-	 * @return false[]|Types\Relation[]
94
-	 */
95
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
96
-		$that = $this;
97
-
98
-		return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
99
-			$term = $that->term_uri_service->get_term( $entity_uri );
100
-			if ( ! $term ) {
101
-				return false;
102
-			}
103
-
104
-			return new Term_Relation( $term->term_id, $that->get_relation_type( $term->term_id ), $subject_type );
105
-		}, $entity_uris );
106
-	}
24
+    /**
25
+     * @var Uri_Service
26
+     */
27
+    private $term_uri_service;
28
+    /**
29
+     * @var Type_Service
30
+     */
31
+    private $term_entity_type_service;
32
+
33
+
34
+    public function __construct() {
35
+        parent::__construct();
36
+        $this->term_uri_service         = Uri_Service::get_instance();
37
+        $this->term_entity_type_service = Type_Service::get_instance();
38
+    }
39
+
40
+    /**
41
+     * @return Term_Relation_Service
42
+     */
43
+    public static function get_instance() {
44
+        return parent::get_instance();
45
+    }
46
+
47
+
48
+    public function get_references( $subject_id, $subject_type ) {
49
+        global $wpdb;
50
+        $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
51
+        $query      = $wpdb->prepare( "SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d",
52
+            $subject_id,
53
+            Object_Type_Enum::TERM,
54
+            $subject_type
55
+        );
56
+
57
+        $term_ids   = $wpdb->get_col( $query );
58
+
59
+        return array_map( function ( $term_id ) {
60
+            return new Term_Reference( $term_id );
61
+        }, $term_ids );
62
+    }
63
+
64
+
65
+    public function get_relations_from_content( $content, $subject_type ) {
66
+        $entity_uris = Object_Relation_Service::get_entity_uris( $content );
67
+        return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
68
+    }
69
+
70
+    /**
71
+     * @param $term_id int Term id.
72
+     */
73
+    public function get_relation_type( $term_id ) {
74
+        $schema               = $this->term_entity_type_service->get_schema(
75
+            $term_id
76
+        );
77
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
78
+
79
+        $entity_type = str_replace( 'wl-', '', $schema['css_class'] );
80
+        foreach ( $classification_boxes as $cb ) {
81
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
82
+                return $cb['id'];
83
+            }
84
+        }
85
+
86
+        return WL_WHAT_RELATION;
87
+    }
88
+
89
+    /**
90
+     * @param $subject_type
91
+     * @param $entity_uris
92
+     *
93
+     * @return false[]|Types\Relation[]
94
+     */
95
+    public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
96
+        $that = $this;
97
+
98
+        return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
99
+            $term = $that->term_uri_service->get_term( $entity_uri );
100
+            if ( ! $term ) {
101
+                return false;
102
+            }
103
+
104
+            return new Term_Relation( $term->term_id, $that->get_relation_type( $term->term_id ), $subject_type );
105
+        }, $entity_uris );
106
+    }
107 107
 
108 108
 
109 109
 }
110 110
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -45,40 +45,40 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 
48
-	public function get_references( $subject_id, $subject_type ) {
48
+	public function get_references($subject_id, $subject_type) {
49 49
 		global $wpdb;
50
-		$table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
51
-		$query      = $wpdb->prepare( "SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d",
50
+		$table_name = $wpdb->prefix.WL_DB_RELATION_INSTANCES_TABLE_NAME;
51
+		$query      = $wpdb->prepare("SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d",
52 52
 			$subject_id,
53 53
 			Object_Type_Enum::TERM,
54 54
 			$subject_type
55 55
 		);
56 56
 
57
-		$term_ids   = $wpdb->get_col( $query );
57
+		$term_ids = $wpdb->get_col($query);
58 58
 
59
-		return array_map( function ( $term_id ) {
60
-			return new Term_Reference( $term_id );
61
-		}, $term_ids );
59
+		return array_map(function($term_id) {
60
+			return new Term_Reference($term_id);
61
+		}, $term_ids);
62 62
 	}
63 63
 
64 64
 
65
-	public function get_relations_from_content( $content, $subject_type ) {
66
-		$entity_uris = Object_Relation_Service::get_entity_uris( $content );
67
-		return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
65
+	public function get_relations_from_content($content, $subject_type) {
66
+		$entity_uris = Object_Relation_Service::get_entity_uris($content);
67
+		return $this->get_relations_from_entity_uris($subject_type, $entity_uris);
68 68
 	}
69 69
 
70 70
 	/**
71 71
 	 * @param $term_id int Term id.
72 72
 	 */
73
-	public function get_relation_type( $term_id ) {
73
+	public function get_relation_type($term_id) {
74 74
 		$schema               = $this->term_entity_type_service->get_schema(
75 75
 			$term_id
76 76
 		);
77
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
77
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
78 78
 
79
-		$entity_type = str_replace( 'wl-', '', $schema['css_class'] );
80
-		foreach ( $classification_boxes as $cb ) {
81
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
79
+		$entity_type = str_replace('wl-', '', $schema['css_class']);
80
+		foreach ($classification_boxes as $cb) {
81
+			if (in_array($entity_type, $cb['registeredTypes'])) {
82 82
 				return $cb['id'];
83 83
 			}
84 84
 		}
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return false[]|Types\Relation[]
94 94
 	 */
95
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
95
+	public function get_relations_from_entity_uris($subject_type, $entity_uris) {
96 96
 		$that = $this;
97 97
 
98
-		return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
99
-			$term = $that->term_uri_service->get_term( $entity_uri );
100
-			if ( ! $term ) {
98
+		return array_map(function($entity_uri) use ($subject_type, $that) {
99
+			$term = $that->term_uri_service->get_term($entity_uri);
100
+			if ( ! $term) {
101 101
 				return false;
102 102
 			}
103 103
 
104
-			return new Term_Relation( $term->term_id, $that->get_relation_type( $term->term_id ), $subject_type );
105
-		}, $entity_uris );
104
+			return new Term_Relation($term->term_id, $that->get_relation_type($term->term_id), $subject_type);
105
+		}, $entity_uris);
106 106
 	}
107 107
 
108 108
 
Please login to merge, or discard this patch.
src/wordlift/relation/class-object-no-annotation-relation-service.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
 class Object_No_Annotation_Relation_Service extends Object_Relation_Service {
14 14
 
15 15
 
16
-	public function get_relations_from_content( $content, $subject_type ) {
17
-		if ( ! isset($_POST['wl_entities'])) {
18
-			return array();
19
-		}
16
+    public function get_relations_from_content( $content, $subject_type ) {
17
+        if ( ! isset($_POST['wl_entities'])) {
18
+            return array();
19
+        }
20 20
 
21
-		$selected_entities = (array) $_POST['wl_entities'];
22
-		// Returns the list of entity ids.
23
-		$entity_uris =  array_keys( $selected_entities );
24
-		return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
25
-	}
21
+        $selected_entities = (array) $_POST['wl_entities'];
22
+        // Returns the list of entity ids.
23
+        $entity_uris =  array_keys( $selected_entities );
24
+        return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
25
+    }
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
 class Object_No_Annotation_Relation_Service extends Object_Relation_Service {
14 14
 
15 15
 
16
-	public function get_relations_from_content( $content, $subject_type ) {
16
+	public function get_relations_from_content($content, $subject_type) {
17 17
 		if ( ! isset($_POST['wl_entities'])) {
18 18
 			return array();
19 19
 		}
20 20
 
21 21
 		$selected_entities = (array) $_POST['wl_entities'];
22 22
 		// Returns the list of entity ids.
23
-		$entity_uris =  array_keys( $selected_entities );
24
-		return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
23
+		$entity_uris = array_keys($selected_entities);
24
+		return $this->get_relations_from_entity_uris($subject_type, $entity_uris);
25 25
 	}
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/relation/class-relation-service-interface.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,30 +17,30 @@
 block discarded – undo
17 17
 
18 18
 interface  Relation_Service_Interface {
19 19
 
20
-	/**
21
-	 * @param $subject_id int
22
-	 * @param int $subject_type {@link Object_Type_Enum}
23
-	 * @return array<Reference>
24
-	 */
25
-	public function get_references( $subject_id, $subject_type );
26
-
27
-
28
-	/**
29
-	 * @param $content string
30
-	 * @param int $subject_type {@link Object_Type_Enum}
31
-	 * @return array<Relation>
32
-	 * Extracts the relations from the post content.
33
-	 */
34
-	public function get_relations_from_content( $content, $subject_type );
35
-
36
-
37
-	/**
38
-	 * @param $subject_type
39
-	 * @param $entity_uris
40
-	 *
41
-	 * @return Relation[] | false[]
42
-	 */
43
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris );
20
+    /**
21
+     * @param $subject_id int
22
+     * @param int $subject_type {@link Object_Type_Enum}
23
+     * @return array<Reference>
24
+     */
25
+    public function get_references( $subject_id, $subject_type );
26
+
27
+
28
+    /**
29
+     * @param $content string
30
+     * @param int $subject_type {@link Object_Type_Enum}
31
+     * @return array<Relation>
32
+     * Extracts the relations from the post content.
33
+     */
34
+    public function get_relations_from_content( $content, $subject_type );
35
+
36
+
37
+    /**
38
+     * @param $subject_type
39
+     * @param $entity_uris
40
+     *
41
+     * @return Relation[] | false[]
42
+     */
43
+    public function get_relations_from_entity_uris( $subject_type, $entity_uris );
44 44
 
45 45
 
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param int $subject_type {@link Object_Type_Enum}
23 23
 	 * @return array<Reference>
24 24
 	 */
25
-	public function get_references( $subject_id, $subject_type );
25
+	public function get_references($subject_id, $subject_type);
26 26
 
27 27
 
28 28
 	/**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @return array<Relation>
32 32
 	 * Extracts the relations from the post content.
33 33
 	 */
34
-	public function get_relations_from_content( $content, $subject_type );
34
+	public function get_relations_from_content($content, $subject_type);
35 35
 
36 36
 
37 37
 	/**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return Relation[] | false[]
42 42
 	 */
43
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris );
43
+	public function get_relations_from_entity_uris($subject_type, $entity_uris);
44 44
 
45 45
 
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/relation/class-post-relation-service.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -17,65 +17,65 @@
 block discarded – undo
17 17
 use Wordlift\Relation\Types\Relation;
18 18
 
19 19
 class Post_Relation_Service extends Singleton implements Relation_Service_Interface {
20
-	/**
21
-	 * @var \Wordlift_Relation_Service
22
-	 */
23
-	private $legacy_post_relation_service;
24
-	/**
25
-	 * @var \Wordlift_Entity_Uri_Service
26
-	 */
27
-	private $entity_uri_service;
28
-	/**
29
-	 * @var \Wordlift_Entity_Service
30
-	 */
31
-	private $entity_service;
20
+    /**
21
+     * @var \Wordlift_Relation_Service
22
+     */
23
+    private $legacy_post_relation_service;
24
+    /**
25
+     * @var \Wordlift_Entity_Uri_Service
26
+     */
27
+    private $entity_uri_service;
28
+    /**
29
+     * @var \Wordlift_Entity_Service
30
+     */
31
+    private $entity_service;
32 32
 
33 33
 
34
-	/**
35
-	 * @return Post_Relation_Service
36
-	 */
37
-	public static function get_instance() {
38
-		return parent::get_instance();
39
-	}
34
+    /**
35
+     * @return Post_Relation_Service
36
+     */
37
+    public static function get_instance() {
38
+        return parent::get_instance();
39
+    }
40 40
 
41
-	public function __construct() {
42
-		parent::__construct();
43
-		$this->legacy_post_relation_service = \Wordlift_Relation_Service::get_instance();
44
-		$this->entity_uri_service           = \Wordlift_Entity_Uri_Service::get_instance();
45
-		$this->entity_service               = \Wordlift_Entity_Service::get_instance();
46
-	}
41
+    public function __construct() {
42
+        parent::__construct();
43
+        $this->legacy_post_relation_service = \Wordlift_Relation_Service::get_instance();
44
+        $this->entity_uri_service           = \Wordlift_Entity_Uri_Service::get_instance();
45
+        $this->entity_service               = \Wordlift_Entity_Service::get_instance();
46
+    }
47 47
 
48 48
 
49
-	public function get_references( $subject_id, $subject_type ) {
50
-		$post_ids = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' );
49
+    public function get_references( $subject_id, $subject_type ) {
50
+        $post_ids = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' );
51 51
 
52
-		return array_map( function ( $post_id ) {
53
-			return new Post_Reference( $post_id );
54
-		}, $post_ids );
55
-	}
52
+        return array_map( function ( $post_id ) {
53
+            return new Post_Reference( $post_id );
54
+        }, $post_ids );
55
+    }
56 56
 
57
-	public function get_relations_from_content( $content, $subject_type ) {
58
-		$entity_uris = Object_Relation_Service::get_entity_uris( $content );
57
+    public function get_relations_from_content( $content, $subject_type ) {
58
+        $entity_uris = Object_Relation_Service::get_entity_uris( $content );
59 59
 
60
-		return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
61
-	}
60
+        return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
61
+    }
62 62
 
63
-	/**
64
-	 * @param $subject_type
65
-	 * @param $entity_uris
66
-	 *
67
-	 * @return false[]|Relation[]
68
-	 */
69
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
70
-		$that = $this;
63
+    /**
64
+     * @param $subject_type
65
+     * @param $entity_uris
66
+     *
67
+     * @return false[]|Relation[]
68
+     */
69
+    public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
70
+        $that = $this;
71 71
 
72
-		return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
73
-			$entity = $that->entity_uri_service->get_entity( $entity_uri );
74
-			if ( ! $entity ) {
75
-				return false;
76
-			}
72
+        return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
73
+            $entity = $that->entity_uri_service->get_entity( $entity_uri );
74
+            if ( ! $entity ) {
75
+                return false;
76
+            }
77 77
 
78
-			return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type );
79
-		}, $entity_uris );
80
-	}
78
+            return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type );
79
+        }, $entity_uris );
80
+    }
81 81
 }
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 
48 48
 
49
-	public function get_references( $subject_id, $subject_type ) {
50
-		$post_ids = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' );
49
+	public function get_references($subject_id, $subject_type) {
50
+		$post_ids = $this->legacy_post_relation_service->get_objects($subject_id, 'ids');
51 51
 
52
-		return array_map( function ( $post_id ) {
53
-			return new Post_Reference( $post_id );
54
-		}, $post_ids );
52
+		return array_map(function($post_id) {
53
+			return new Post_Reference($post_id);
54
+		}, $post_ids);
55 55
 	}
56 56
 
57
-	public function get_relations_from_content( $content, $subject_type ) {
58
-		$entity_uris = Object_Relation_Service::get_entity_uris( $content );
57
+	public function get_relations_from_content($content, $subject_type) {
58
+		$entity_uris = Object_Relation_Service::get_entity_uris($content);
59 59
 
60
-		return $this->get_relations_from_entity_uris( $subject_type, $entity_uris );
60
+		return $this->get_relations_from_entity_uris($subject_type, $entity_uris);
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return false[]|Relation[]
68 68
 	 */
69
-	public function get_relations_from_entity_uris( $subject_type, $entity_uris ) {
69
+	public function get_relations_from_entity_uris($subject_type, $entity_uris) {
70 70
 		$that = $this;
71 71
 
72
-		return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
73
-			$entity = $that->entity_uri_service->get_entity( $entity_uri );
74
-			if ( ! $entity ) {
72
+		return array_map(function($entity_uri) use ($subject_type, $that) {
73
+			$entity = $that->entity_uri_service->get_entity($entity_uri);
74
+			if ( ! $entity) {
75 75
 				return false;
76 76
 			}
77 77
 
78
-			return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type );
79
-		}, $entity_uris );
78
+			return new Post_Relation($entity->ID, $that->entity_service->get_classification_scope_for($entity->ID), $subject_type);
79
+		}, $entity_uris);
80 80
 	}
81 81
 }
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/features/class-feature-utils.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
  */
14 14
 class Feature_Utils {
15 15
 
16
-	/**
17
-	 * Returns true if the feature is enabled.
18
-	 *
19
-	 * @param string $feature_slug Feature slug.
20
-	 *
21
-	 * @return bool
22
-	 */
23
-	public static function is_feature_on( $feature_slug, $default  ) {
24
-		return apply_filters( 'wl_feature__enable__' . $feature_slug, $default );
25
-	}
16
+    /**
17
+     * Returns true if the feature is enabled.
18
+     *
19
+     * @param string $feature_slug Feature slug.
20
+     *
21
+     * @return bool
22
+     */
23
+    public static function is_feature_on( $feature_slug, $default  ) {
24
+        return apply_filters( 'wl_feature__enable__' . $feature_slug, $default );
25
+    }
26 26
 
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@
 block discarded – undo
20 20
 	 *
21 21
 	 * @return bool
22 22
 	 */
23
-	public static function is_feature_on( $feature_slug, $default  ) {
24
-		return apply_filters( 'wl_feature__enable__' . $feature_slug, $default );
23
+	public static function is_feature_on($feature_slug, $default) {
24
+		return apply_filters('wl_feature__enable__'.$feature_slug, $default);
25 25
 	}
26 26
 
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/analysis/class-v1-analysis-service.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  */
13 13
 class V1_Analysis_Service extends Abstract_Analysis_Service {
14 14
 
15
-	public function get_analysis_response( $data, $content_type, $post_id ) {
16
-		return $this->api_service->post_custom_content_type( 'analysis/single', $data, $content_type );
17
-	}
15
+    public function get_analysis_response( $data, $content_type, $post_id ) {
16
+        return $this->api_service->post_custom_content_type( 'analysis/single', $data, $content_type );
17
+    }
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  */
13 13
 class V1_Analysis_Service extends Abstract_Analysis_Service {
14 14
 
15
-	public function get_analysis_response( $data, $content_type, $post_id ) {
16
-		return $this->api_service->post_custom_content_type( 'analysis/single', $data, $content_type );
15
+	public function get_analysis_response($data, $content_type, $post_id) {
16
+		return $this->api_service->post_custom_content_type('analysis/single', $data, $content_type);
17 17
 	}
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.