Completed
Pull Request — develop (#1576)
by Naveen
01:10
created
src/includes/properties/class-wordlift-entity-property-service.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,37 +12,37 @@
 block discarded – undo
12 12
  */
13 13
 class Wordlift_Entity_Property_Service extends Wordlift_Simple_Property_Service {
14 14
 
15
-	/**
16
-	 * {@inheritdoc}
17
-	 */
18
-	public function get( $id, $meta_key, $type ) {
19
-
20
-		$entity_service = Wordlift_Entity_Service::get_instance();
21
-
22
-		// Map each returned value to a Wordlift_Property_Entity_Reference.
23
-		return array_map(
24
-			function ( $item ) use ( $entity_service ) {
25
-
26
-				$regex = '/^(post|term)_(\d+)$/m';
27
-				if ( preg_match( $regex, $item, $matches ) ) {
28
-
29
-					$object_type = Object_Type_Enum::from_string( $matches[1] );
30
-					$identifier  = (int) $matches[2];
31
-					if ( Object_Type_Enum::POST === $object_type ) {
32
-						return new Post_Reference( $identifier );
33
-					} elseif ( Object_Type_Enum::TERM === $object_type ) {
34
-						return new Term_Reference( $identifier );
35
-					}
36
-				}
37
-
38
-				// If the $item is a number and it's an existing post, return the
39
-				// URI of the referenced entity. Otherwise return the value.
40
-				return is_numeric( $item ) && null !== get_post( $item )
41
-				? new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $item ), (int) $item )
42
-				: $item;
43
-			},
44
-			parent::get( $id, $meta_key, $type )
45
-		);
46
-	}
15
+    /**
16
+     * {@inheritdoc}
17
+     */
18
+    public function get( $id, $meta_key, $type ) {
19
+
20
+        $entity_service = Wordlift_Entity_Service::get_instance();
21
+
22
+        // Map each returned value to a Wordlift_Property_Entity_Reference.
23
+        return array_map(
24
+            function ( $item ) use ( $entity_service ) {
25
+
26
+                $regex = '/^(post|term)_(\d+)$/m';
27
+                if ( preg_match( $regex, $item, $matches ) ) {
28
+
29
+                    $object_type = Object_Type_Enum::from_string( $matches[1] );
30
+                    $identifier  = (int) $matches[2];
31
+                    if ( Object_Type_Enum::POST === $object_type ) {
32
+                        return new Post_Reference( $identifier );
33
+                    } elseif ( Object_Type_Enum::TERM === $object_type ) {
34
+                        return new Term_Reference( $identifier );
35
+                    }
36
+                }
37
+
38
+                // If the $item is a number and it's an existing post, return the
39
+                // URI of the referenced entity. Otherwise return the value.
40
+                return is_numeric( $item ) && null !== get_post( $item )
41
+                ? new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $item ), (int) $item )
42
+                : $item;
43
+            },
44
+            parent::get( $id, $meta_key, $type )
45
+        );
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@
 block discarded – undo
15 15
 	/**
16 16
 	 * {@inheritdoc}
17 17
 	 */
18
-	public function get( $id, $meta_key, $type ) {
18
+	public function get($id, $meta_key, $type) {
19 19
 
20 20
 		$entity_service = Wordlift_Entity_Service::get_instance();
21 21
 
22 22
 		// Map each returned value to a Wordlift_Property_Entity_Reference.
23 23
 		return array_map(
24
-			function ( $item ) use ( $entity_service ) {
24
+			function($item) use ($entity_service) {
25 25
 
26 26
 				$regex = '/^(post|term)_(\d+)$/m';
27
-				if ( preg_match( $regex, $item, $matches ) ) {
27
+				if (preg_match($regex, $item, $matches)) {
28 28
 
29
-					$object_type = Object_Type_Enum::from_string( $matches[1] );
29
+					$object_type = Object_Type_Enum::from_string($matches[1]);
30 30
 					$identifier  = (int) $matches[2];
31
-					if ( Object_Type_Enum::POST === $object_type ) {
32
-						return new Post_Reference( $identifier );
33
-					} elseif ( Object_Type_Enum::TERM === $object_type ) {
34
-						return new Term_Reference( $identifier );
31
+					if (Object_Type_Enum::POST === $object_type) {
32
+						return new Post_Reference($identifier);
33
+					} elseif (Object_Type_Enum::TERM === $object_type) {
34
+						return new Term_Reference($identifier);
35 35
 					}
36 36
 				}
37 37
 
38 38
 				// If the $item is a number and it's an existing post, return the
39 39
 				// URI of the referenced entity. Otherwise return the value.
40
-				return is_numeric( $item ) && null !== get_post( $item )
41
-				? new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $item ), (int) $item )
40
+				return is_numeric($item) && null !== get_post($item)
41
+				? new Wordlift_Property_Entity_Reference($entity_service->get_uri($item), (int) $item)
42 42
 				: $item;
43 43
 			},
44
-			parent::get( $id, $meta_key, $type )
44
+			parent::get($id, $meta_key, $type)
45 45
 		);
46 46
 	}
47 47
 
Please login to merge, or discard this patch.