Completed
Push — master ( 82e5c6...f7ebf6 )
by Naveen
35s queued 12s
created
src/modules/food-kg/load.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -17,54 +17,54 @@
 block discarded – undo
17 17
 
18 18
 
19 19
 if ( ! defined( 'ABSPATH' ) ) {
20
-	exit;
20
+    exit;
21 21
 }
22 22
 
23 23
 define( 'WL_FOOD_KG_FILE', __FILE__ );
24 24
 define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) );
25 25
 
26 26
 function __wl_foodkg__load() {
27
-	// Autoloader for dependencies.
28
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) {
29
-		require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php';
30
-	}
27
+    // Autoloader for dependencies.
28
+    if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) {
29
+        require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php';
30
+    }
31 31
 
32
-	// Autoloader for plugin itself.
33
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) {
34
-		require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php';
35
-	}
32
+    // Autoloader for plugin itself.
33
+    if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) {
34
+        require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php';
35
+    }
36 36
 
37
-	$container_builder = new ContainerBuilder();
38
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
39
-	$loader->load( 'services.yml' );
40
-	$container_builder->compile();
37
+    $container_builder = new ContainerBuilder();
38
+    $loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
39
+    $loader->load( 'services.yml' );
40
+    $container_builder->compile();
41 41
 
42
-	$notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
43
-	$notices->register_hooks();
42
+    $notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
43
+    $notices->register_hooks();
44 44
 
45
-	/**
46
-	 * @var Preconditions $preconditions
47
-	 */
48
-	$preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
49
-	if ( ! $preconditions->pass() ) {
50
-		return;
51
-	}
45
+    /**
46
+     * @var Preconditions $preconditions
47
+     */
48
+    $preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
49
+    if ( ! $preconditions->pass() ) {
50
+        return;
51
+    }
52 52
 
53
-	$module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
54
-	$module->register_hooks();
53
+    $module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
54
+    $module->register_hooks();
55 55
 
56
-	/** @var Jsonld $jsonld */
57
-	$jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
58
-	$jsonld->register_hooks();
56
+    /** @var Jsonld $jsonld */
57
+    $jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
58
+    $jsonld->register_hooks();
59 59
 
60
-	/** @var Main_Ingredient_Jsonld $jsonld */
61
-	$main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
62
-	$main_ingredient_jsonld->register_hooks();
60
+    /** @var Main_Ingredient_Jsonld $jsonld */
61
+    $main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
62
+    $main_ingredient_jsonld->register_hooks();
63 63
 
64
-	if ( is_admin() ) {
65
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
66
-		$page->register_hooks();
67
-	}
64
+    if ( is_admin() ) {
65
+        $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
66
+        $page->register_hooks();
67
+    }
68 68
 }
69 69
 
70 70
 add_action( 'plugins_loaded', '__wl_foodkg__load' );
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -16,56 +16,56 @@
 block discarded – undo
16 16
 use Wordlift\Modules\Food_Kg\Preconditions;
17 17
 
18 18
 
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
23
-define( 'WL_FOOD_KG_FILE', __FILE__ );
24
-define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) );
23
+define('WL_FOOD_KG_FILE', __FILE__);
24
+define('WL_FOOD_KG_DIR_PATH', dirname(WL_FOOD_KG_FILE));
25 25
 
26 26
 function __wl_foodkg__load() {
27 27
 	// Autoloader for dependencies.
28
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) {
29
-		require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php';
28
+	if (file_exists(WL_FOOD_KG_DIR_PATH.'/third-party/vendor/scoper-autoload.php')) {
29
+		require WL_FOOD_KG_DIR_PATH.'/third-party/vendor/scoper-autoload.php';
30 30
 	}
31 31
 
32 32
 	// Autoloader for plugin itself.
33
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) {
34
-		require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php';
33
+	if (file_exists(WL_FOOD_KG_DIR_PATH.'/includes/vendor/autoload.php')) {
34
+		require WL_FOOD_KG_DIR_PATH.'/includes/vendor/autoload.php';
35 35
 	}
36 36
 
37 37
 	$container_builder = new ContainerBuilder();
38
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
39
-	$loader->load( 'services.yml' );
38
+	$loader            = new YamlFileLoader($container_builder, new FileLocator(__DIR__));
39
+	$loader->load('services.yml');
40 40
 	$container_builder->compile();
41 41
 
42
-	$notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
42
+	$notices = $container_builder->get('Wordlift\Modules\Food_Kg\Notices');
43 43
 	$notices->register_hooks();
44 44
 
45 45
 	/**
46 46
 	 * @var Preconditions $preconditions
47 47
 	 */
48
-	$preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
49
-	if ( ! $preconditions->pass() ) {
48
+	$preconditions = $container_builder->get('Wordlift\Modules\Food_Kg\Preconditions');
49
+	if ( ! $preconditions->pass()) {
50 50
 		return;
51 51
 	}
52 52
 
53
-	$module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
53
+	$module = $container_builder->get('Wordlift\Modules\Food_Kg\Module');
54 54
 	$module->register_hooks();
55 55
 
56 56
 	/** @var Jsonld $jsonld */
57
-	$jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
57
+	$jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Jsonld');
58 58
 	$jsonld->register_hooks();
59 59
 
60 60
 	/** @var Main_Ingredient_Jsonld $jsonld */
61
-	$main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
61
+	$main_ingredient_jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld');
62 62
 	$main_ingredient_jsonld->register_hooks();
63 63
 
64
-	if ( is_admin() ) {
65
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
64
+	if (is_admin()) {
65
+		$page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Page');
66 66
 		$page->register_hooks();
67 67
 	}
68 68
 }
69 69
 
70
-add_action( 'plugins_loaded', '__wl_foodkg__load' );
70
+add_action('plugins_loaded', '__wl_foodkg__load');
71 71
 
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Module.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -7,61 +7,61 @@
 block discarded – undo
7 7
 
8 8
 class Module {
9 9
 
10
-	const RUN_EVENT = 'wl_food_kg__run';
11
-
12
-	/**
13
-	 * @var Api_Service_Ext
14
-	 */
15
-	private $api_service;
16
-
17
-	/**
18
-	 * @var Recipe_Lift_Strategy
19
-	 */
20
-	private $recipe_lift_strategy;
21
-
22
-	/**
23
-	 * @param Api_Service_Ext $api_service
24
-	 * @param Recipe_Lift_Strategy $recipe_lift_strategy
25
-	 */
26
-	public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
27
-		$this->api_service          = $api_service;
28
-		$this->recipe_lift_strategy = $recipe_lift_strategy;
29
-	}
30
-
31
-	public function register_hooks() {
32
-		add_action( 'wl_key_updated', [ $this, '__key_updated' ] );
33
-		add_action( self::RUN_EVENT, [ $this, '__run' ] );
34
-		add_action( 'wp_ajax_wl_food_kg__run', [ $this, '__run' ] );
35
-	}
36
-
37
-	public function __key_updated() {
38
-		try {
39
-			$me_response    = $this->api_service->me();
40
-			$has_food_kg    = isset( $me_response->networks )
41
-			                  && array_reduce( $me_response->networks, [ $this, '__has_food_kg' ], false );
42
-			$next_scheduled = wp_next_scheduled( self::RUN_EVENT );
43
-
44
-			// We're connected to the Food KG, but not yet scheduled.
45
-			if ( $has_food_kg && ! $next_scheduled ) {
46
-				wp_schedule_event( time(), 'daily', self::RUN_EVENT );
47
-			}
48
-
49
-			// We're not connected to the Food KG, but we're scheduled.
50
-			if ( ! $has_food_kg && $next_scheduled ) {
51
-				wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
52
-			}
53
-
54
-		} catch ( \Exception $e ) {
55
-
56
-		}
57
-	}
58
-
59
-	public function __run() {
60
-		$this->recipe_lift_strategy->run();
61
-	}
62
-
63
-	private function __has_food_kg( $carry, $item ) {
64
-		return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
65
-	}
10
+    const RUN_EVENT = 'wl_food_kg__run';
11
+
12
+    /**
13
+     * @var Api_Service_Ext
14
+     */
15
+    private $api_service;
16
+
17
+    /**
18
+     * @var Recipe_Lift_Strategy
19
+     */
20
+    private $recipe_lift_strategy;
21
+
22
+    /**
23
+     * @param Api_Service_Ext $api_service
24
+     * @param Recipe_Lift_Strategy $recipe_lift_strategy
25
+     */
26
+    public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
27
+        $this->api_service          = $api_service;
28
+        $this->recipe_lift_strategy = $recipe_lift_strategy;
29
+    }
30
+
31
+    public function register_hooks() {
32
+        add_action( 'wl_key_updated', [ $this, '__key_updated' ] );
33
+        add_action( self::RUN_EVENT, [ $this, '__run' ] );
34
+        add_action( 'wp_ajax_wl_food_kg__run', [ $this, '__run' ] );
35
+    }
36
+
37
+    public function __key_updated() {
38
+        try {
39
+            $me_response    = $this->api_service->me();
40
+            $has_food_kg    = isset( $me_response->networks )
41
+                              && array_reduce( $me_response->networks, [ $this, '__has_food_kg' ], false );
42
+            $next_scheduled = wp_next_scheduled( self::RUN_EVENT );
43
+
44
+            // We're connected to the Food KG, but not yet scheduled.
45
+            if ( $has_food_kg && ! $next_scheduled ) {
46
+                wp_schedule_event( time(), 'daily', self::RUN_EVENT );
47
+            }
48
+
49
+            // We're not connected to the Food KG, but we're scheduled.
50
+            if ( ! $has_food_kg && $next_scheduled ) {
51
+                wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
52
+            }
53
+
54
+        } catch ( \Exception $e ) {
55
+
56
+        }
57
+    }
58
+
59
+    public function __run() {
60
+        $this->recipe_lift_strategy->run();
61
+    }
62
+
63
+    private function __has_food_kg( $carry, $item ) {
64
+        return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,35 +23,35 @@  discard block
 block discarded – undo
23 23
 	 * @param Api_Service_Ext $api_service
24 24
 	 * @param Recipe_Lift_Strategy $recipe_lift_strategy
25 25
 	 */
26
-	public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
26
+	public function __construct(Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy) {
27 27
 		$this->api_service          = $api_service;
28 28
 		$this->recipe_lift_strategy = $recipe_lift_strategy;
29 29
 	}
30 30
 
31 31
 	public function register_hooks() {
32
-		add_action( 'wl_key_updated', [ $this, '__key_updated' ] );
33
-		add_action( self::RUN_EVENT, [ $this, '__run' ] );
34
-		add_action( 'wp_ajax_wl_food_kg__run', [ $this, '__run' ] );
32
+		add_action('wl_key_updated', [$this, '__key_updated']);
33
+		add_action(self::RUN_EVENT, [$this, '__run']);
34
+		add_action('wp_ajax_wl_food_kg__run', [$this, '__run']);
35 35
 	}
36 36
 
37 37
 	public function __key_updated() {
38 38
 		try {
39 39
 			$me_response    = $this->api_service->me();
40
-			$has_food_kg    = isset( $me_response->networks )
41
-			                  && array_reduce( $me_response->networks, [ $this, '__has_food_kg' ], false );
42
-			$next_scheduled = wp_next_scheduled( self::RUN_EVENT );
40
+			$has_food_kg    = isset($me_response->networks)
41
+			                  && array_reduce($me_response->networks, [$this, '__has_food_kg'], false);
42
+			$next_scheduled = wp_next_scheduled(self::RUN_EVENT);
43 43
 
44 44
 			// We're connected to the Food KG, but not yet scheduled.
45
-			if ( $has_food_kg && ! $next_scheduled ) {
46
-				wp_schedule_event( time(), 'daily', self::RUN_EVENT );
45
+			if ($has_food_kg && ! $next_scheduled) {
46
+				wp_schedule_event(time(), 'daily', self::RUN_EVENT);
47 47
 			}
48 48
 
49 49
 			// We're not connected to the Food KG, but we're scheduled.
50
-			if ( ! $has_food_kg && $next_scheduled ) {
51
-				wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
50
+			if ( ! $has_food_kg && $next_scheduled) {
51
+				wp_unschedule_event($next_scheduled, self::RUN_EVENT);
52 52
 			}
53 53
 
54
-		} catch ( \Exception $e ) {
54
+		} catch (\Exception $e) {
55 55
 
56 56
 		}
57 57
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		$this->recipe_lift_strategy->run();
61 61
 	}
62 62
 
63
-	private function __has_food_kg( $carry, $item ) {
63
+	private function __has_food_kg($carry, $item) {
64 64
 		return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.