Completed
Push — develop ( 067cb9...77afdc )
by David
01:24
created
src/modules/food-kg/includes/Ingredients_Taxonomy_Recipe_Lift_Strategy.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -23,37 +23,37 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	private $content_service;
25 25
 
26
-	public function __construct( Ingredients_Client $ingredients_client, Notices $notices, Content_Service $content_service ) {
26
+	public function __construct(Ingredients_Client $ingredients_client, Notices $notices, Content_Service $content_service) {
27 27
 		$this->ingredients_client = $ingredients_client;
28 28
 		$this->notices            = $notices;
29 29
 		$this->content_service    = $content_service;
30 30
 	}
31 31
 
32 32
 	public function run() {
33
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
33
+		$this->notices->queue('info', __('WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift'));
34 34
 
35 35
 		/**
36 36
 		 * @var WP_Term[] $terms
37 37
 		 */
38
-		$terms                = get_terms(
38
+		$terms = get_terms(
39 39
 			array(
40 40
 				'taxonomy'   => 'wprm_ingredient',
41 41
 				'fields'     => 'all',
42 42
 				'hide_empty' => false,
43 43
 			)
44 44
 		);
45
-		$filtered_terms       = $this->terms_without_about_jsonld( $terms );
46
-		$filtered_terms_names = array_map( array( $this, 'term_name' ), $filtered_terms );
47
-		$ingredients          = $this->ingredients_client->ingredients( $filtered_terms_names );
45
+		$filtered_terms       = $this->terms_without_about_jsonld($terms);
46
+		$filtered_terms_names = array_map(array($this, 'term_name'), $filtered_terms);
47
+		$ingredients          = $this->ingredients_client->ingredients($filtered_terms_names);
48 48
 
49
-		foreach ( $ingredients as $key => $value ) {
50
-			$term = get_term_by( 'name', $key, 'wprm_ingredient' );
51
-			if ( ! isset( $term ) ) {
49
+		foreach ($ingredients as $key => $value) {
50
+			$term = get_term_by('name', $key, 'wprm_ingredient');
51
+			if ( ! isset($term)) {
52 52
 				continue;
53 53
 			}
54 54
 
55 55
 			$this->content_service->set_about_jsonld(
56
-				Wordpress_Content_Id::create_term( $term->term_id ),
56
+				Wordpress_Content_Id::create_term($term->term_id),
57 57
 				$value
58 58
 			);
59 59
 
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 		}
64 64
 
65 65
 		// Clean up caches.
66
-		do_action( 'wl_ttl_cache_cleaner__flush' );
66
+		do_action('wl_ttl_cache_cleaner__flush');
67 67
 
68 68
 		/**
69 69
 		 * @@todo add notification that procedure is complete, with information about the number of processed items vs
70 70
 		 *   total items
71 71
 		 */
72
-		$count_terms        = count( $filtered_terms );
73
-		$count_lifted_terms = count( $ingredients );
72
+		$count_terms        = count($filtered_terms);
73
+		$count_lifted_terms = count($ingredients);
74 74
 		/* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */
75
-		$this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) );
75
+		$this->notices->queue('info', sprintf(__('WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift'), $count_lifted_terms, $count_terms));
76 76
 	}
77 77
 
78 78
 	/**
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return WP_Term[]
82 82
 	 */
83
-	private function terms_without_about_jsonld( $terms ) {
84
-		return array_filter( $terms, array( $this, 'term_has_not_about_jsonld' ) );
83
+	private function terms_without_about_jsonld($terms) {
84
+		return array_filter($terms, array($this, 'term_has_not_about_jsonld'));
85 85
 	}
86 86
 
87 87
 	/**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return bool true if the term has an about_jsonld otherwise false.
91 91
 	 */
92
-	private function term_has_not_about_jsonld( $term ) {
92
+	private function term_has_not_about_jsonld($term) {
93 93
 		$about_jsonld = $this->content_service->get_about_jsonld(
94
-			Wordpress_Content_Id::create_term( $term->term_id )
94
+			Wordpress_Content_Id::create_term($term->term_id)
95 95
 		);
96 96
 
97 97
 		return $about_jsonld === null;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return string
104 104
 	 */
105
-	public function term_name( $term ) {
105
+	public function term_name($term) {
106 106
 		return $term->name;
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Term_Entity/Food_Kg_Term_Entity_Runner.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	private $ingredients_client;
27 27
 
28
-	public function __construct( Food_Kg_Ingredients_Term_Store $store, Content_Service $content_service, Ingredients_Client $ingredients_client ) {
28
+	public function __construct(Food_Kg_Ingredients_Term_Store $store, Content_Service $content_service, Ingredients_Client $ingredients_client) {
29 29
 		$this->store              = $store;
30 30
 		$this->content_service    = $content_service;
31 31
 		$this->ingredients_client = $ingredients_client;
32 32
 	}
33 33
 
34 34
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
35
-	public function run( $last_id ) {
35
+	public function run($last_id) {
36 36
 
37
-		$items = $this->store->list_items( $last_id, 100 );
37
+		$items = $this->store->list_items($last_id, 100);
38 38
 		$names = array_column(
39 39
 			array_map(
40
-				function ( $item ) {
40
+				function($item) {
41 41
 					return (array) $item;
42 42
 				},
43 43
 				$items
@@ -45,23 +45,23 @@  discard block
 block discarded – undo
45 45
 			'name'
46 46
 		);
47 47
 
48
-		$ingredients = $this->ingredients_client->ingredients( $names );
48
+		$ingredients = $this->ingredients_client->ingredients($names);
49 49
 
50
-		foreach ( $ingredients as $key => $value ) {
51
-			$term = get_term_by( 'name', $key, 'wprm_ingredient' );
52
-			if ( ! isset( $term ) || $this->term_has_about_jsonld( $term ) ) {
50
+		foreach ($ingredients as $key => $value) {
51
+			$term = get_term_by('name', $key, 'wprm_ingredient');
52
+			if ( ! isset($term) || $this->term_has_about_jsonld($term)) {
53 53
 				continue;
54 54
 			}
55 55
 
56
-			$content_id = Wordpress_Content_Id::create_term( $term->term_id );
57
-			$this->content_service->set_about_jsonld( $content_id, $value );
56
+			$content_id = Wordpress_Content_Id::create_term($term->term_id);
57
+			$this->content_service->set_about_jsonld($content_id, $value);
58 58
 		}
59 59
 
60
-		$count        = count( $items );
61
-		$last_item    = end( $items );
62
-		$last_item_id = ( isset( $last_item->term_id ) ? $last_item->term_id : null );
60
+		$count        = count($items);
61
+		$last_item    = end($items);
62
+		$last_item_id = (isset($last_item->term_id) ? $last_item->term_id : null);
63 63
 
64
-		return array( $count, $last_item_id );
64
+		return array($count, $last_item_id);
65 65
 	}
66 66
 
67 67
 	/**
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return bool true if the term has an about_jsonld otherwise false.
82 82
 	 */
83
-	private function term_has_about_jsonld( $term ) {
83
+	private function term_has_about_jsonld($term) {
84 84
 		$about_jsonld = $this->content_service->get_about_jsonld(
85
-			Wordpress_Content_Id::create_term( $term->term_id )
85
+			Wordpress_Content_Id::create_term($term->term_id)
86 86
 		);
87 87
 
88 88
 		return $about_jsonld !== null;
Please login to merge, or discard this patch.