Completed
Pull Request — develop (#1633)
by Naveen
01:05
created
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.
src/wordlift/entity/class-entity-helper.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,75 +14,75 @@
 block discarded – undo
14 14
 
15 15
 class Entity_Helper {
16 16
 
17
-	private $entity_uri_service;
18
-
19
-	private $entity_service;
20
-
21
-	/**
22
-	 * Entity_Helper constructor.
23
-	 *
24
-	 * @param Wordlift_Entity_Uri_Service $entity_uri_service
25
-	 * @param Wordlift_Entity_Service     $entity_service
26
-	 */
27
-	protected function __construct( $entity_uri_service, $entity_service ) {
28
-
29
-		$this->entity_uri_service = $entity_uri_service;
30
-		$this->entity_service     = $entity_service;
31
-
32
-	}
33
-
34
-	private static $instance;
35
-
36
-	public static function get_instance() {
37
-		if ( ! isset( self::$instance ) ) {
38
-			self::$instance = new self( Wordlift_Entity_Uri_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
39
-		}
40
-
41
-		return self::$instance;
42
-	}
43
-
44
-	/**
45
-	 * Maps the provided URIs to local URIs.
46
-	 *
47
-	 * The input array is filtered out of the local URIs. Then each URI is checked with itemid and sameAs in the local
48
-	 * database. If found a mapping is added from the external URI to the local URI.
49
-	 *
50
-	 * An array of mappings is returned, where the key is the external URI and the value is the local URI.
51
-	 *
52
-	 * @param array $uris An array of URIs.
53
-	 *
54
-	 * @return array The mappings array.
55
-	 */
56
-	public function map_many_to_local( $uris ) {
57
-
58
-		// Filter only the external URIs.
59
-		$entity_uri_service = $this->entity_uri_service;
60
-		$external_uris      = array_filter(
61
-			$uris,
62
-			function ( $item ) use ( $entity_uri_service ) {
63
-				return ! $entity_uri_service->is_internal( $item );
64
-			}
65
-		);
66
-
67
-		// Preload the URIs.
68
-		$entity_uri_service->preload_uris( $external_uris );
69
-
70
-		$mappings = array();
71
-		foreach ( $external_uris as $external_uri ) {
72
-			if ( empty( $external_uri ) ) {
73
-				continue;
74
-			}
75
-
76
-			$entity = $entity_uri_service->get_entity( $external_uri );
77
-			if ( null !== $entity ) {
78
-
79
-				// Get the internal URI.
80
-				$internal_uri              = $this->entity_service->get_uri( $entity->ID );
81
-				$mappings[ $external_uri ] = $internal_uri;
82
-			}
83
-		}
84
-
85
-		return $mappings;
86
-	}
17
+    private $entity_uri_service;
18
+
19
+    private $entity_service;
20
+
21
+    /**
22
+     * Entity_Helper constructor.
23
+     *
24
+     * @param Wordlift_Entity_Uri_Service $entity_uri_service
25
+     * @param Wordlift_Entity_Service     $entity_service
26
+     */
27
+    protected function __construct( $entity_uri_service, $entity_service ) {
28
+
29
+        $this->entity_uri_service = $entity_uri_service;
30
+        $this->entity_service     = $entity_service;
31
+
32
+    }
33
+
34
+    private static $instance;
35
+
36
+    public static function get_instance() {
37
+        if ( ! isset( self::$instance ) ) {
38
+            self::$instance = new self( Wordlift_Entity_Uri_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
39
+        }
40
+
41
+        return self::$instance;
42
+    }
43
+
44
+    /**
45
+     * Maps the provided URIs to local URIs.
46
+     *
47
+     * The input array is filtered out of the local URIs. Then each URI is checked with itemid and sameAs in the local
48
+     * database. If found a mapping is added from the external URI to the local URI.
49
+     *
50
+     * An array of mappings is returned, where the key is the external URI and the value is the local URI.
51
+     *
52
+     * @param array $uris An array of URIs.
53
+     *
54
+     * @return array The mappings array.
55
+     */
56
+    public function map_many_to_local( $uris ) {
57
+
58
+        // Filter only the external URIs.
59
+        $entity_uri_service = $this->entity_uri_service;
60
+        $external_uris      = array_filter(
61
+            $uris,
62
+            function ( $item ) use ( $entity_uri_service ) {
63
+                return ! $entity_uri_service->is_internal( $item );
64
+            }
65
+        );
66
+
67
+        // Preload the URIs.
68
+        $entity_uri_service->preload_uris( $external_uris );
69
+
70
+        $mappings = array();
71
+        foreach ( $external_uris as $external_uri ) {
72
+            if ( empty( $external_uri ) ) {
73
+                continue;
74
+            }
75
+
76
+            $entity = $entity_uri_service->get_entity( $external_uri );
77
+            if ( null !== $entity ) {
78
+
79
+                // Get the internal URI.
80
+                $internal_uri              = $this->entity_service->get_uri( $entity->ID );
81
+                $mappings[ $external_uri ] = $internal_uri;
82
+            }
83
+        }
84
+
85
+        return $mappings;
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param Wordlift_Entity_Uri_Service $entity_uri_service
25 25
 	 * @param Wordlift_Entity_Service     $entity_service
26 26
 	 */
27
-	protected function __construct( $entity_uri_service, $entity_service ) {
27
+	protected function __construct($entity_uri_service, $entity_service) {
28 28
 
29 29
 		$this->entity_uri_service = $entity_uri_service;
30 30
 		$this->entity_service     = $entity_service;
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	private static $instance;
35 35
 
36 36
 	public static function get_instance() {
37
-		if ( ! isset( self::$instance ) ) {
38
-			self::$instance = new self( Wordlift_Entity_Uri_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
37
+		if ( ! isset(self::$instance)) {
38
+			self::$instance = new self(Wordlift_Entity_Uri_Service::get_instance(), Wordlift_Entity_Service::get_instance());
39 39
 		}
40 40
 
41 41
 		return self::$instance;
@@ -53,32 +53,32 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return array The mappings array.
55 55
 	 */
56
-	public function map_many_to_local( $uris ) {
56
+	public function map_many_to_local($uris) {
57 57
 
58 58
 		// Filter only the external URIs.
59 59
 		$entity_uri_service = $this->entity_uri_service;
60 60
 		$external_uris      = array_filter(
61 61
 			$uris,
62
-			function ( $item ) use ( $entity_uri_service ) {
63
-				return ! $entity_uri_service->is_internal( $item );
62
+			function($item) use ($entity_uri_service) {
63
+				return ! $entity_uri_service->is_internal($item);
64 64
 			}
65 65
 		);
66 66
 
67 67
 		// Preload the URIs.
68
-		$entity_uri_service->preload_uris( $external_uris );
68
+		$entity_uri_service->preload_uris($external_uris);
69 69
 
70 70
 		$mappings = array();
71
-		foreach ( $external_uris as $external_uri ) {
72
-			if ( empty( $external_uri ) ) {
71
+		foreach ($external_uris as $external_uri) {
72
+			if (empty($external_uri)) {
73 73
 				continue;
74 74
 			}
75 75
 
76
-			$entity = $entity_uri_service->get_entity( $external_uri );
77
-			if ( null !== $entity ) {
76
+			$entity = $entity_uri_service->get_entity($external_uri);
77
+			if (null !== $entity) {
78 78
 
79 79
 				// Get the internal URI.
80
-				$internal_uri              = $this->entity_service->get_uri( $entity->ID );
81
-				$mappings[ $external_uri ] = $internal_uri;
80
+				$internal_uri              = $this->entity_service->get_uri($entity->ID);
81
+				$mappings[$external_uri] = $internal_uri;
82 82
 			}
83 83
 		}
84 84
 
Please login to merge, or discard this patch.
src/wordlift/entity/class-entity-uri-generator.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,57 +8,57 @@
 block discarded – undo
8 8
 
9 9
 class Entity_Uri_Generator {
10 10
 
11
-	public static function create_uri( $object_type_enum, $id ) {
11
+    public static function create_uri( $object_type_enum, $id ) {
12 12
 
13
-		switch ( $object_type_enum ) {
14
-			case Object_Type_Enum::POST:
15
-				$post = get_post( $id );
16
-				if ( ! isset( $post ) || in_array( $post->post_status, array( 'auto-draft', 'inherit' ), true ) ) {
17
-					return null;
18
-				}
13
+        switch ( $object_type_enum ) {
14
+            case Object_Type_Enum::POST:
15
+                $post = get_post( $id );
16
+                if ( ! isset( $post ) || in_array( $post->post_status, array( 'auto-draft', 'inherit' ), true ) ) {
17
+                    return null;
18
+                }
19 19
 
20
-				$slug = $post->post_name ? $post->post_name : sanitize_title( $post->post_title ) . '-' . $post->ID;
20
+                $slug = $post->post_name ? $post->post_name : sanitize_title( $post->post_title ) . '-' . $post->ID;
21 21
 
22
-				return self::ensure_unique( $post->post_type . '/' . $slug );
22
+                return self::ensure_unique( $post->post_type . '/' . $slug );
23 23
 
24
-			case Object_Type_Enum::TERM:
25
-				$term = get_term( $id );
26
-				if ( ! is_a( $term, 'WP_Term' ) ) {
27
-					return null;
28
-				}
24
+            case Object_Type_Enum::TERM:
25
+                $term = get_term( $id );
26
+                if ( ! is_a( $term, 'WP_Term' ) ) {
27
+                    return null;
28
+                }
29 29
 
30
-				return self::ensure_unique( $term->taxonomy . '/' . $term->slug );
30
+                return self::ensure_unique( $term->taxonomy . '/' . $term->slug );
31 31
 
32
-			case Object_Type_Enum::USER:
33
-				$user = get_user_by( 'id', $id );
32
+            case Object_Type_Enum::USER:
33
+                $user = get_user_by( 'id', $id );
34 34
 
35
-				if ( ! is_a( $user, 'WP_User' ) ) {
36
-					return null;
37
-				}
35
+                if ( ! is_a( $user, 'WP_User' ) ) {
36
+                    return null;
37
+                }
38 38
 
39
-				return self::ensure_unique( 'user/' . $user->user_nicename );
39
+                return self::ensure_unique( 'user/' . $user->user_nicename );
40 40
 
41
-			default:
42
-		}
41
+            default:
42
+        }
43 43
 
44
-		return null;
45
-	}
44
+        return null;
45
+    }
46 46
 
47
-	/**
48
-	 * @throws Exception when an error occurs.
49
-	 */
50
-	private static function ensure_unique( $rel_uri ) {
51
-		for ( $try_rel_uri = $rel_uri, $i = 2; $i < 100; $i ++ ) {
52
-			$content = Wordpress_Content_Service::get_instance()->get_by_entity_id( $try_rel_uri );
53
-			if ( ! isset( $content ) ) {
54
-				return $try_rel_uri;
55
-			}
47
+    /**
48
+     * @throws Exception when an error occurs.
49
+     */
50
+    private static function ensure_unique( $rel_uri ) {
51
+        for ( $try_rel_uri = $rel_uri, $i = 2; $i < 100; $i ++ ) {
52
+            $content = Wordpress_Content_Service::get_instance()->get_by_entity_id( $try_rel_uri );
53
+            if ( ! isset( $content ) ) {
54
+                return $try_rel_uri;
55
+            }
56 56
 
57
-			$try_rel_uri = $rel_uri . '-' . $i;
58
-		}
57
+            $try_rel_uri = $rel_uri . '-' . $i;
58
+        }
59 59
 
60
-		// Giving up.
61
-		return $rel_uri . '-' . uniqid();
62
-	}
60
+        // Giving up.
61
+        return $rel_uri . '-' . uniqid();
62
+    }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Entity_Uri_Generator {
10 10
 
11
-	public static function create_uri( $object_type_enum, $id ) {
11
+	public static function create_uri($object_type_enum, $id) {
12 12
 
13
-		switch ( $object_type_enum ) {
13
+		switch ($object_type_enum) {
14 14
 			case Object_Type_Enum::POST:
15
-				$post = get_post( $id );
16
-				if ( ! isset( $post ) || in_array( $post->post_status, array( 'auto-draft', 'inherit' ), true ) ) {
15
+				$post = get_post($id);
16
+				if ( ! isset($post) || in_array($post->post_status, array('auto-draft', 'inherit'), true)) {
17 17
 					return null;
18 18
 				}
19 19
 
20
-				$slug = $post->post_name ? $post->post_name : sanitize_title( $post->post_title ) . '-' . $post->ID;
20
+				$slug = $post->post_name ? $post->post_name : sanitize_title($post->post_title).'-'.$post->ID;
21 21
 
22
-				return self::ensure_unique( $post->post_type . '/' . $slug );
22
+				return self::ensure_unique($post->post_type.'/'.$slug);
23 23
 
24 24
 			case Object_Type_Enum::TERM:
25
-				$term = get_term( $id );
26
-				if ( ! is_a( $term, 'WP_Term' ) ) {
25
+				$term = get_term($id);
26
+				if ( ! is_a($term, 'WP_Term')) {
27 27
 					return null;
28 28
 				}
29 29
 
30
-				return self::ensure_unique( $term->taxonomy . '/' . $term->slug );
30
+				return self::ensure_unique($term->taxonomy.'/'.$term->slug);
31 31
 
32 32
 			case Object_Type_Enum::USER:
33
-				$user = get_user_by( 'id', $id );
33
+				$user = get_user_by('id', $id);
34 34
 
35
-				if ( ! is_a( $user, 'WP_User' ) ) {
35
+				if ( ! is_a($user, 'WP_User')) {
36 36
 					return null;
37 37
 				}
38 38
 
39
-				return self::ensure_unique( 'user/' . $user->user_nicename );
39
+				return self::ensure_unique('user/'.$user->user_nicename);
40 40
 
41 41
 			default:
42 42
 		}
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * @throws Exception when an error occurs.
49 49
 	 */
50
-	private static function ensure_unique( $rel_uri ) {
51
-		for ( $try_rel_uri = $rel_uri, $i = 2; $i < 100; $i ++ ) {
52
-			$content = Wordpress_Content_Service::get_instance()->get_by_entity_id( $try_rel_uri );
53
-			if ( ! isset( $content ) ) {
50
+	private static function ensure_unique($rel_uri) {
51
+		for ($try_rel_uri = $rel_uri, $i = 2; $i < 100; $i++) {
52
+			$content = Wordpress_Content_Service::get_instance()->get_by_entity_id($try_rel_uri);
53
+			if ( ! isset($content)) {
54 54
 				return $try_rel_uri;
55 55
 			}
56 56
 
57
-			$try_rel_uri = $rel_uri . '-' . $i;
57
+			$try_rel_uri = $rel_uri.'-'.$i;
58 58
 		}
59 59
 
60 60
 		// Giving up.
61
-		return $rel_uri . '-' . uniqid();
61
+		return $rel_uri.'-'.uniqid();
62 62
 	}
63 63
 
64 64
 }
Please login to merge, or discard this patch.
src/wordlift/google-addon-integration/class-loader.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
  */
12 12
 class Loader extends Default_Loader {
13 13
 
14
-	public function init_all_dependencies() {
15
-		new Import_Page();
16
-		$rest_endpoint = new Rest_Endpoint();
17
-		$rest_endpoint->init();
18
-	}
14
+    public function init_all_dependencies() {
15
+        new Import_Page();
16
+        $rest_endpoint = new Rest_Endpoint();
17
+        $rest_endpoint->init();
18
+    }
19 19
 
20
-	public function get_feature_slug() {
21
-		return 'google-addon-integration';
22
-	}
20
+    public function get_feature_slug() {
21
+        return 'google-addon-integration';
22
+    }
23 23
 
24
-	public function get_feature_default_value() {
25
-		return true;
26
-	}
24
+    public function get_feature_default_value() {
25
+        return true;
26
+    }
27 27
 }
Please login to merge, or discard this patch.