Completed
Push — master ( 587793...0cd805 )
by Naveen
01:22 queued 12s
created
src/wordlift/entity/class-entity-store.php 2 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -32,142 +32,142 @@
 block discarded – undo
32 32
  */
33 33
 class Entity_Store {
34 34
 
35
-	protected function __construct() {
36
-	}
37
-
38
-	private static $instance = null;
39
-
40
-	/**
41
-	 * Get the Entity_Store singleton, lazily initialized.
42
-	 *
43
-	 * @return Entity_Store The singleton.
44
-	 */
45
-	public static function get_instance() {
46
-		if ( ! isset( self::$instance ) ) {
47
-			self::$instance = new Entity_Store();
48
-		}
49
-
50
-		return self::$instance;
51
-	}
52
-
53
-	/**
54
-	 * Create and persist an entity.
55
-	 *
56
-	 * @param array  $params {
57
-	 *       The entity parameters.
58
-	 *
59
-	 * @type string|array $labels A label, or an array of labels. The first label is set as post title.
60
-	 * @type string $description The entity description, stored in the post content.
61
-	 * @type string|array $same_as One or more entity URIs, stored in the sameAs post meta.
62
-	 * }
63
-	 *
64
-	 * @param string $post_status The post status, by default `draft`.
65
-	 *
66
-	 * @return int|\WP_Error
67
-	 * @throws \Exception when an error occurs.
68
-	 */
69
-	public function create( $params, $post_status = 'draft' ) {
70
-
71
-		$args = wp_parse_args(
72
-			$params,
73
-			array(
74
-				'labels'      => array(),
75
-				'description' => '',
76
-				'same_as'     => array(),
77
-			)
78
-		);
79
-
80
-		// Use the first label as `post_title`.
81
-		$labels = (array) $args['labels'];
82
-		$label  = array_shift( $labels );
83
-
84
-		$post_id = wp_insert_post(
85
-			array(
86
-				'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
87
-				'post_status'  => $post_status,
88
-				'post_title'   => $label,
89
-				'post_name'    => sanitize_title( $label ),
90
-				'post_content' => $args['description'],
91
-			)
92
-		);
93
-
94
-		// Bail out if we've got an error.
95
-		if ( empty( $post_id ) || is_wp_error( $post_id ) ) {
96
-			throw new \Exception( 'An error occurred while creating an entity.' );
97
-		}
98
-
99
-		Wordlift_Entity_Service::get_instance()
100
-							   ->set_alternative_labels( $post_id, array_diff( $labels, array( $label ) ) );
101
-		$this->merge_post_meta(
102
-			$post_id,
103
-			\Wordlift_Schema_Service::FIELD_SAME_AS,
104
-			(array) $args['same_as'],
105
-			(array) Wordpress_Content_Service::get_instance()->get_entity_id( Wordpress_Content_Id::create_post( $post_id ) )
106
-		);
107
-
108
-		return $post_id;
109
-	}
110
-
111
-	/**
112
-	 * Update an entity.
113
-	 *
114
-	 * @param array $params {
115
-	 *
116
-	 * @type int $ID The post ID.
117
-	 * @type string|array One or more labels to add to the synonyms.
118
-	 * @type string|array One or more URIs to add to the sameAs.
119
-	 * }
120
-	 *
121
-	 * @return int The post id.
122
-	 */
123
-	public function update( $params ) {
124
-
125
-		$args = wp_parse_args(
126
-			$params,
127
-			array(
128
-				'ID'      => 0,
129
-				'labels'  => array(),
130
-				'same_as' => array(),
131
-			)
132
-		);
133
-
134
-		$post_id = $args['ID'];
135
-
136
-		// Save synonyms except title.
137
-		Wordlift_Entity_Service::get_instance()
138
-							   ->append_alternative_labels( $post_id, array_diff( (array) $args['labels'], array( get_the_title( $post_id ) ) ) );
139
-
140
-		$this->merge_post_meta(
141
-			$post_id,
142
-			\Wordlift_Schema_Service::FIELD_SAME_AS,
143
-			(array) $args['same_as'],
144
-			(array) Wordpress_Content_Service::get_instance()->get_entity_id( Wordpress_Content_Id::create_post( $post_id ) )
145
-		);
146
-
147
-		return $post_id;
148
-	}
149
-
150
-	/**
151
-	 * Merge the post meta.
152
-	 *
153
-	 * @param int          $post_id The post ID.
154
-	 * @param string       $meta_key The post meta key.
155
-	 * @param string|array $values One or more values to add.
156
-	 * @param string|array $exclusions An additional list of values to exclude.
157
-	 */
158
-	private function merge_post_meta( $post_id, $meta_key, $values, $exclusions = array() ) {
159
-
160
-		$existing = array_merge(
161
-			(array) $exclusions,
162
-			get_post_meta( $post_id, $meta_key )
163
-		);
164
-
165
-		foreach ( (array) $values as $value ) {
166
-			// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
167
-			if ( ! in_array( $value, $existing ) ) {
168
-				add_post_meta( $post_id, $meta_key, $value );
169
-			}
170
-		}
171
-	}
35
+    protected function __construct() {
36
+    }
37
+
38
+    private static $instance = null;
39
+
40
+    /**
41
+     * Get the Entity_Store singleton, lazily initialized.
42
+     *
43
+     * @return Entity_Store The singleton.
44
+     */
45
+    public static function get_instance() {
46
+        if ( ! isset( self::$instance ) ) {
47
+            self::$instance = new Entity_Store();
48
+        }
49
+
50
+        return self::$instance;
51
+    }
52
+
53
+    /**
54
+     * Create and persist an entity.
55
+     *
56
+     * @param array  $params {
57
+     *       The entity parameters.
58
+     *
59
+     * @type string|array $labels A label, or an array of labels. The first label is set as post title.
60
+     * @type string $description The entity description, stored in the post content.
61
+     * @type string|array $same_as One or more entity URIs, stored in the sameAs post meta.
62
+     * }
63
+     *
64
+     * @param string $post_status The post status, by default `draft`.
65
+     *
66
+     * @return int|\WP_Error
67
+     * @throws \Exception when an error occurs.
68
+     */
69
+    public function create( $params, $post_status = 'draft' ) {
70
+
71
+        $args = wp_parse_args(
72
+            $params,
73
+            array(
74
+                'labels'      => array(),
75
+                'description' => '',
76
+                'same_as'     => array(),
77
+            )
78
+        );
79
+
80
+        // Use the first label as `post_title`.
81
+        $labels = (array) $args['labels'];
82
+        $label  = array_shift( $labels );
83
+
84
+        $post_id = wp_insert_post(
85
+            array(
86
+                'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
87
+                'post_status'  => $post_status,
88
+                'post_title'   => $label,
89
+                'post_name'    => sanitize_title( $label ),
90
+                'post_content' => $args['description'],
91
+            )
92
+        );
93
+
94
+        // Bail out if we've got an error.
95
+        if ( empty( $post_id ) || is_wp_error( $post_id ) ) {
96
+            throw new \Exception( 'An error occurred while creating an entity.' );
97
+        }
98
+
99
+        Wordlift_Entity_Service::get_instance()
100
+                                ->set_alternative_labels( $post_id, array_diff( $labels, array( $label ) ) );
101
+        $this->merge_post_meta(
102
+            $post_id,
103
+            \Wordlift_Schema_Service::FIELD_SAME_AS,
104
+            (array) $args['same_as'],
105
+            (array) Wordpress_Content_Service::get_instance()->get_entity_id( Wordpress_Content_Id::create_post( $post_id ) )
106
+        );
107
+
108
+        return $post_id;
109
+    }
110
+
111
+    /**
112
+     * Update an entity.
113
+     *
114
+     * @param array $params {
115
+     *
116
+     * @type int $ID The post ID.
117
+     * @type string|array One or more labels to add to the synonyms.
118
+     * @type string|array One or more URIs to add to the sameAs.
119
+     * }
120
+     *
121
+     * @return int The post id.
122
+     */
123
+    public function update( $params ) {
124
+
125
+        $args = wp_parse_args(
126
+            $params,
127
+            array(
128
+                'ID'      => 0,
129
+                'labels'  => array(),
130
+                'same_as' => array(),
131
+            )
132
+        );
133
+
134
+        $post_id = $args['ID'];
135
+
136
+        // Save synonyms except title.
137
+        Wordlift_Entity_Service::get_instance()
138
+                                ->append_alternative_labels( $post_id, array_diff( (array) $args['labels'], array( get_the_title( $post_id ) ) ) );
139
+
140
+        $this->merge_post_meta(
141
+            $post_id,
142
+            \Wordlift_Schema_Service::FIELD_SAME_AS,
143
+            (array) $args['same_as'],
144
+            (array) Wordpress_Content_Service::get_instance()->get_entity_id( Wordpress_Content_Id::create_post( $post_id ) )
145
+        );
146
+
147
+        return $post_id;
148
+    }
149
+
150
+    /**
151
+     * Merge the post meta.
152
+     *
153
+     * @param int          $post_id The post ID.
154
+     * @param string       $meta_key The post meta key.
155
+     * @param string|array $values One or more values to add.
156
+     * @param string|array $exclusions An additional list of values to exclude.
157
+     */
158
+    private function merge_post_meta( $post_id, $meta_key, $values, $exclusions = array() ) {
159
+
160
+        $existing = array_merge(
161
+            (array) $exclusions,
162
+            get_post_meta( $post_id, $meta_key )
163
+        );
164
+
165
+        foreach ( (array) $values as $value ) {
166
+            // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
167
+            if ( ! in_array( $value, $existing ) ) {
168
+                add_post_meta( $post_id, $meta_key, $value );
169
+            }
170
+        }
171
+    }
172 172
 
173 173
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @return Entity_Store The singleton.
44 44
 	 */
45 45
 	public static function get_instance() {
46
-		if ( ! isset( self::$instance ) ) {
46
+		if ( ! isset(self::$instance)) {
47 47
 			self::$instance = new Entity_Store();
48 48
 		}
49 49
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @return int|\WP_Error
67 67
 	 * @throws \Exception when an error occurs.
68 68
 	 */
69
-	public function create( $params, $post_status = 'draft' ) {
69
+	public function create($params, $post_status = 'draft') {
70 70
 
71 71
 		$args = wp_parse_args(
72 72
 			$params,
@@ -79,30 +79,30 @@  discard block
 block discarded – undo
79 79
 
80 80
 		// Use the first label as `post_title`.
81 81
 		$labels = (array) $args['labels'];
82
-		$label  = array_shift( $labels );
82
+		$label  = array_shift($labels);
83 83
 
84 84
 		$post_id = wp_insert_post(
85 85
 			array(
86 86
 				'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
87 87
 				'post_status'  => $post_status,
88 88
 				'post_title'   => $label,
89
-				'post_name'    => sanitize_title( $label ),
89
+				'post_name'    => sanitize_title($label),
90 90
 				'post_content' => $args['description'],
91 91
 			)
92 92
 		);
93 93
 
94 94
 		// Bail out if we've got an error.
95
-		if ( empty( $post_id ) || is_wp_error( $post_id ) ) {
96
-			throw new \Exception( 'An error occurred while creating an entity.' );
95
+		if (empty($post_id) || is_wp_error($post_id)) {
96
+			throw new \Exception('An error occurred while creating an entity.');
97 97
 		}
98 98
 
99 99
 		Wordlift_Entity_Service::get_instance()
100
-							   ->set_alternative_labels( $post_id, array_diff( $labels, array( $label ) ) );
100
+							   ->set_alternative_labels($post_id, array_diff($labels, array($label)));
101 101
 		$this->merge_post_meta(
102 102
 			$post_id,
103 103
 			\Wordlift_Schema_Service::FIELD_SAME_AS,
104 104
 			(array) $args['same_as'],
105
-			(array) Wordpress_Content_Service::get_instance()->get_entity_id( Wordpress_Content_Id::create_post( $post_id ) )
105
+			(array) Wordpress_Content_Service::get_instance()->get_entity_id(Wordpress_Content_Id::create_post($post_id))
106 106
 		);
107 107
 
108 108
 		return $post_id;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @return int The post id.
122 122
 	 */
123
-	public function update( $params ) {
123
+	public function update($params) {
124 124
 
125 125
 		$args = wp_parse_args(
126 126
 			$params,
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 
136 136
 		// Save synonyms except title.
137 137
 		Wordlift_Entity_Service::get_instance()
138
-							   ->append_alternative_labels( $post_id, array_diff( (array) $args['labels'], array( get_the_title( $post_id ) ) ) );
138
+							   ->append_alternative_labels($post_id, array_diff((array) $args['labels'], array(get_the_title($post_id))));
139 139
 
140 140
 		$this->merge_post_meta(
141 141
 			$post_id,
142 142
 			\Wordlift_Schema_Service::FIELD_SAME_AS,
143 143
 			(array) $args['same_as'],
144
-			(array) Wordpress_Content_Service::get_instance()->get_entity_id( Wordpress_Content_Id::create_post( $post_id ) )
144
+			(array) Wordpress_Content_Service::get_instance()->get_entity_id(Wordpress_Content_Id::create_post($post_id))
145 145
 		);
146 146
 
147 147
 		return $post_id;
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
 	 * @param string|array $values One or more values to add.
156 156
 	 * @param string|array $exclusions An additional list of values to exclude.
157 157
 	 */
158
-	private function merge_post_meta( $post_id, $meta_key, $values, $exclusions = array() ) {
158
+	private function merge_post_meta($post_id, $meta_key, $values, $exclusions = array()) {
159 159
 
160 160
 		$existing = array_merge(
161 161
 			(array) $exclusions,
162
-			get_post_meta( $post_id, $meta_key )
162
+			get_post_meta($post_id, $meta_key)
163 163
 		);
164 164
 
165
-		foreach ( (array) $values as $value ) {
165
+		foreach ((array) $values as $value) {
166 166
 			// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
167
-			if ( ! in_array( $value, $existing ) ) {
168
-				add_post_meta( $post_id, $meta_key, $value );
167
+			if ( ! in_array($value, $existing)) {
168
+				add_post_meta($post_id, $meta_key, $value);
169 169
 			}
170 170
 		}
171 171
 	}
Please login to merge, or discard this patch.
src/wordlift/entity/remote-entity-importer/class-remote-entity-importer.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
 
7 7
 interface Remote_Entity_Importer {
8 8
 
9
-	/**
10
-	 * @return Wordpress_Content_Id|boolean
11
-	 * Returns content id or false.
12
-	 */
13
-	public function import();
9
+    /**
10
+     * @return Wordpress_Content_Id|boolean
11
+     * Returns content id or false.
12
+     */
13
+    public function import();
14 14
 
15 15
 }
Please login to merge, or discard this patch.
entity/remote-entity-importer/class-invalid-remote-entity-importer.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
  */
8 8
 class Invalid_Remote_Entity_Importer implements Remote_Entity_Importer {
9 9
 
10
-	public function import() {
11
-		// Cant import invalid entities.
12
-		return false;
13
-	}
10
+    public function import() {
11
+        // Cant import invalid entities.
12
+        return false;
13
+    }
14 14
 
15 15
 }
Please login to merge, or discard this patch.
entity/remote-entity-importer/class-valid-remote-entity-importer.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -8,39 +8,39 @@
 block discarded – undo
8 8
 
9 9
 class Valid_Remote_Entity_Importer implements Remote_Entity_Importer {
10 10
 
11
-	/**
12
-	 * @var Valid_Remote_Entity
13
-	 */
14
-	private $entity;
15
-
16
-	/**
17
-	 * @param $entity Valid_Remote_Entity
18
-	 */
19
-	public function __construct( $entity ) {
20
-		$this->entity = $entity;
21
-	}
22
-
23
-	public function import() {
24
-
25
-		$entity_type_service = Wordlift_Entity_Type_Service::get_instance();
26
-
27
-		$post_id = wp_insert_post(
28
-			array(
29
-				'post_title'   => $this->entity->get_name(),
30
-				'post_content' => $this->entity->get_description(),
31
-				'post_status'  => 'draft',
32
-				'post_type'    => 'entity',
33
-			)
34
-		);
35
-
36
-		foreach ( $this->entity->get_types() as $type ) {
37
-			$entity_type_service->set( $post_id, "http://schema.org/$type", false );
38
-		}
39
-
40
-		foreach ( $this->entity->get_same_as() as $same_as ) {
41
-			add_post_meta( $post_id, 'entity_same_as', $same_as );
42
-		}
43
-
44
-		return Wordpress_Content_Id::create_post( $post_id );
45
-	}
11
+    /**
12
+     * @var Valid_Remote_Entity
13
+     */
14
+    private $entity;
15
+
16
+    /**
17
+     * @param $entity Valid_Remote_Entity
18
+     */
19
+    public function __construct( $entity ) {
20
+        $this->entity = $entity;
21
+    }
22
+
23
+    public function import() {
24
+
25
+        $entity_type_service = Wordlift_Entity_Type_Service::get_instance();
26
+
27
+        $post_id = wp_insert_post(
28
+            array(
29
+                'post_title'   => $this->entity->get_name(),
30
+                'post_content' => $this->entity->get_description(),
31
+                'post_status'  => 'draft',
32
+                'post_type'    => 'entity',
33
+            )
34
+        );
35
+
36
+        foreach ( $this->entity->get_types() as $type ) {
37
+            $entity_type_service->set( $post_id, "http://schema.org/$type", false );
38
+        }
39
+
40
+        foreach ( $this->entity->get_same_as() as $same_as ) {
41
+            add_post_meta( $post_id, 'entity_same_as', $same_as );
42
+        }
43
+
44
+        return Wordpress_Content_Id::create_post( $post_id );
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @param $entity Valid_Remote_Entity
18 18
 	 */
19
-	public function __construct( $entity ) {
19
+	public function __construct($entity) {
20 20
 		$this->entity = $entity;
21 21
 	}
22 22
 
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 			)
34 34
 		);
35 35
 
36
-		foreach ( $this->entity->get_types() as $type ) {
37
-			$entity_type_service->set( $post_id, "http://schema.org/$type", false );
36
+		foreach ($this->entity->get_types() as $type) {
37
+			$entity_type_service->set($post_id, "http://schema.org/$type", false);
38 38
 		}
39 39
 
40
-		foreach ( $this->entity->get_same_as() as $same_as ) {
41
-			add_post_meta( $post_id, 'entity_same_as', $same_as );
40
+		foreach ($this->entity->get_same_as() as $same_as) {
41
+			add_post_meta($post_id, 'entity_same_as', $same_as);
42 42
 		}
43 43
 
44
-		return Wordpress_Content_Id::create_post( $post_id );
44
+		return Wordpress_Content_Id::create_post($post_id);
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
src/wordlift/entity/remote-entity/class-url-to-remote-entity-converter.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
 
7 7
 class Url_To_Remote_Entity_Converter {
8 8
 
9
-	/**
10
-	 * @param $url
11
-	 *
12
-	 * @return Remote_Entity
13
-	 */
14
-	public static function convert( $url ) {
15
-		$target_path = '/id/' . preg_replace( '@^(https?)://@', '$1/', $url );
16
-		$response    = Default_Api_Service::get_instance()->get( $target_path );
9
+    /**
10
+     * @param $url
11
+     *
12
+     * @return Remote_Entity
13
+     */
14
+    public static function convert( $url ) {
15
+        $target_path = '/id/' . preg_replace( '@^(https?)://@', '$1/', $url );
16
+        $response    = Default_Api_Service::get_instance()->get( $target_path );
17 17
 
18
-		return Remote_Entity_Factory::from_response( $url, $response );
19
-	}
18
+        return Remote_Entity_Factory::from_response( $url, $response );
19
+    }
20 20
 
21 21
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 	 *
12 12
 	 * @return Remote_Entity
13 13
 	 */
14
-	public static function convert( $url ) {
15
-		$target_path = '/id/' . preg_replace( '@^(https?)://@', '$1/', $url );
16
-		$response    = Default_Api_Service::get_instance()->get( $target_path );
14
+	public static function convert($url) {
15
+		$target_path = '/id/'.preg_replace('@^(https?)://@', '$1/', $url);
16
+		$response    = Default_Api_Service::get_instance()->get($target_path);
17 17
 
18
-		return Remote_Entity_Factory::from_response( $url, $response );
18
+		return Remote_Entity_Factory::from_response($url, $response);
19 19
 	}
20 20
 
21 21
 }
Please login to merge, or discard this patch.
src/wordlift/entity/remote-entity/class-invalid-remote-entity.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,19 +4,19 @@
 block discarded – undo
4 4
 
5 5
 class Invalid_Remote_Entity implements Remote_Entity {
6 6
 
7
-	public function get_name() {
8
-		// TODO: Implement getName() method.
9
-	}
7
+    public function get_name() {
8
+        // TODO: Implement getName() method.
9
+    }
10 10
 
11
-	public function get_description() {
12
-		// TODO: Implement getDescription() method.
13
-	}
11
+    public function get_description() {
12
+        // TODO: Implement getDescription() method.
13
+    }
14 14
 
15
-	public function get_same_as() {
16
-		// TODO: Implement getSameAs() method.
17
-	}
15
+    public function get_same_as() {
16
+        // TODO: Implement getSameAs() method.
17
+    }
18 18
 
19
-	public function get_types() {
20
-		// TODO: Implement getTypes() method.
21
-	}
19
+    public function get_types() {
20
+        // TODO: Implement getTypes() method.
21
+    }
22 22
 }
Please login to merge, or discard this patch.
src/wordlift/entity/remote-entity/class-remote-entity-factory.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -4,47 +4,47 @@
 block discarded – undo
4 4
 
5 5
 class Remote_Entity_Factory {
6 6
 
7
-	/**
8
-	 *
9
-	 * @param $entity_url string
10
-	 * @param $response \Wordlift\Api\Response
11
-	 *
12
-	 * @return Remote_Entity
13
-	 */
14
-	public static function from_response( $entity_url, $response ) {
15
-
16
-		if ( ! $response->is_success() ) {
17
-			return new Invalid_Remote_Entity();
18
-		}
19
-
20
-		$entity_data = json_decode( $response->get_body(), true );
21
-
22
-		if ( ! $entity_data ) {
23
-			return new Invalid_Remote_Entity();
24
-		}
25
-
26
-		if ( ! array_key_exists( '@type', $entity_data )
27
-			 || ! array_key_exists( 'name', $entity_data )
28
-			 || ! array_key_exists( 'description', $entity_data ) ) {
29
-
30
-			return new Invalid_Remote_Entity();
31
-		}
32
-
33
-		return new Valid_Remote_Entity(
34
-			self::may_be_wrap_array( $entity_data['@type'] ),
35
-			$entity_data['name'],
36
-			$entity_data['description'],
37
-			array_merge( array( $entity_url ), self::may_be_wrap_array( $entity_data['sameAs'] ) )
38
-		);
39
-
40
-	}
41
-
42
-	private static function may_be_wrap_array( $el ) {
43
-		if ( is_array( $el ) ) {
44
-			return $el;
45
-		}
46
-
47
-		return array( $el );
48
-	}
7
+    /**
8
+     *
9
+     * @param $entity_url string
10
+     * @param $response \Wordlift\Api\Response
11
+     *
12
+     * @return Remote_Entity
13
+     */
14
+    public static function from_response( $entity_url, $response ) {
15
+
16
+        if ( ! $response->is_success() ) {
17
+            return new Invalid_Remote_Entity();
18
+        }
19
+
20
+        $entity_data = json_decode( $response->get_body(), true );
21
+
22
+        if ( ! $entity_data ) {
23
+            return new Invalid_Remote_Entity();
24
+        }
25
+
26
+        if ( ! array_key_exists( '@type', $entity_data )
27
+             || ! array_key_exists( 'name', $entity_data )
28
+             || ! array_key_exists( 'description', $entity_data ) ) {
29
+
30
+            return new Invalid_Remote_Entity();
31
+        }
32
+
33
+        return new Valid_Remote_Entity(
34
+            self::may_be_wrap_array( $entity_data['@type'] ),
35
+            $entity_data['name'],
36
+            $entity_data['description'],
37
+            array_merge( array( $entity_url ), self::may_be_wrap_array( $entity_data['sameAs'] ) )
38
+        );
39
+
40
+    }
41
+
42
+    private static function may_be_wrap_array( $el ) {
43
+        if ( is_array( $el ) ) {
44
+            return $el;
45
+        }
46
+
47
+        return array( $el );
48
+    }
49 49
 
50 50
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,40 +11,40 @@
 block discarded – undo
11 11
 	 *
12 12
 	 * @return Remote_Entity
13 13
 	 */
14
-	public static function from_response( $entity_url, $response ) {
14
+	public static function from_response($entity_url, $response) {
15 15
 
16
-		if ( ! $response->is_success() ) {
16
+		if ( ! $response->is_success()) {
17 17
 			return new Invalid_Remote_Entity();
18 18
 		}
19 19
 
20
-		$entity_data = json_decode( $response->get_body(), true );
20
+		$entity_data = json_decode($response->get_body(), true);
21 21
 
22
-		if ( ! $entity_data ) {
22
+		if ( ! $entity_data) {
23 23
 			return new Invalid_Remote_Entity();
24 24
 		}
25 25
 
26
-		if ( ! array_key_exists( '@type', $entity_data )
27
-			 || ! array_key_exists( 'name', $entity_data )
28
-			 || ! array_key_exists( 'description', $entity_data ) ) {
26
+		if ( ! array_key_exists('@type', $entity_data)
27
+			 || ! array_key_exists('name', $entity_data)
28
+			 || ! array_key_exists('description', $entity_data)) {
29 29
 
30 30
 			return new Invalid_Remote_Entity();
31 31
 		}
32 32
 
33 33
 		return new Valid_Remote_Entity(
34
-			self::may_be_wrap_array( $entity_data['@type'] ),
34
+			self::may_be_wrap_array($entity_data['@type']),
35 35
 			$entity_data['name'],
36 36
 			$entity_data['description'],
37
-			array_merge( array( $entity_url ), self::may_be_wrap_array( $entity_data['sameAs'] ) )
37
+			array_merge(array($entity_url), self::may_be_wrap_array($entity_data['sameAs']))
38 38
 		);
39 39
 
40 40
 	}
41 41
 
42
-	private static function may_be_wrap_array( $el ) {
43
-		if ( is_array( $el ) ) {
42
+	private static function may_be_wrap_array($el) {
43
+		if (is_array($el)) {
44 44
 			return $el;
45 45
 		}
46 46
 
47
-		return array( $el );
47
+		return array($el);
48 48
 	}
49 49
 
50 50
 }
Please login to merge, or discard this patch.
src/wordlift/entity/remote-entity/class-valid-remote-entity.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -4,50 +4,50 @@
 block discarded – undo
4 4
 
5 5
 class Valid_Remote_Entity implements Remote_Entity {
6 6
 
7
-	/**
8
-	 * @var array<string>
9
-	 */
10
-	private $types;
11
-
12
-	/**
13
-	 * Title or name of the entity.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	private $name;
18
-	/**
19
-	 * The entity description.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	private $description;
24
-	/**
25
-	 * An array of sameAs urls.
26
-	 *
27
-	 * @var array<string>
28
-	 */
29
-	private $same_as;
30
-
31
-	public function __construct( $types, $name, $description, $same_as ) {
32
-		$this->types       = $types;
33
-		$this->name        = $name;
34
-		$this->description = $description;
35
-		$this->same_as     = $same_as;
36
-	}
37
-
38
-	public function get_name() {
39
-		return $this->name;
40
-	}
41
-
42
-	public function get_description() {
43
-		return $this->description;
44
-	}
45
-
46
-	public function get_same_as() {
47
-		return $this->same_as;
48
-	}
49
-
50
-	public function get_types() {
51
-		return $this->types;
52
-	}
7
+    /**
8
+     * @var array<string>
9
+     */
10
+    private $types;
11
+
12
+    /**
13
+     * Title or name of the entity.
14
+     *
15
+     * @var string
16
+     */
17
+    private $name;
18
+    /**
19
+     * The entity description.
20
+     *
21
+     * @var string
22
+     */
23
+    private $description;
24
+    /**
25
+     * An array of sameAs urls.
26
+     *
27
+     * @var array<string>
28
+     */
29
+    private $same_as;
30
+
31
+    public function __construct( $types, $name, $description, $same_as ) {
32
+        $this->types       = $types;
33
+        $this->name        = $name;
34
+        $this->description = $description;
35
+        $this->same_as     = $same_as;
36
+    }
37
+
38
+    public function get_name() {
39
+        return $this->name;
40
+    }
41
+
42
+    public function get_description() {
43
+        return $this->description;
44
+    }
45
+
46
+    public function get_same_as() {
47
+        return $this->same_as;
48
+    }
49
+
50
+    public function get_types() {
51
+        return $this->types;
52
+    }
53 53
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 	 */
29 29
 	private $same_as;
30 30
 
31
-	public function __construct( $types, $name, $description, $same_as ) {
31
+	public function __construct($types, $name, $description, $same_as) {
32 32
 		$this->types       = $types;
33 33
 		$this->name        = $name;
34 34
 		$this->description = $description;
Please login to merge, or discard this patch.
src/wordlift/entity/remote-entity/class-remote-entity.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,24 +4,24 @@
 block discarded – undo
4 4
 
5 5
 interface Remote_Entity {
6 6
 
7
-	/**
8
-	 * @return string
9
-	 */
10
-	public function get_name();
7
+    /**
8
+     * @return string
9
+     */
10
+    public function get_name();
11 11
 
12
-	/**
13
-	 * @return string
14
-	 */
15
-	public function get_description();
12
+    /**
13
+     * @return string
14
+     */
15
+    public function get_description();
16 16
 
17
-	/**
18
-	 * @return array<string>
19
-	 */
20
-	public function get_same_as();
17
+    /**
18
+     * @return array<string>
19
+     */
20
+    public function get_same_as();
21 21
 
22
-	/**
23
-	 * @return array<string>
24
-	 */
25
-	public function get_types();
22
+    /**
23
+     * @return array<string>
24
+     */
25
+    public function get_types();
26 26
 
27 27
 }
Please login to merge, or discard this patch.