Completed
Push — develop ( 2b0757...37b1a2 )
by Naveen
34s queued 12s
created
src/modules/food-kg/load.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -18,96 +18,96 @@
 block discarded – undo
18 18
 use Wordlift\Task\Background\Background_Task_Factory;
19 19
 use Wordlift\Task\Single_Call_Task;
20 20
 
21
-if ( ! defined( 'ABSPATH' ) ) {
21
+if ( ! defined('ABSPATH')) {
22 22
 	exit;
23 23
 }
24 24
 
25
-define( 'WL_FOOD_KG_FILE', __FILE__ );
26
-define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) );
25
+define('WL_FOOD_KG_FILE', __FILE__);
26
+define('WL_FOOD_KG_DIR_PATH', dirname(WL_FOOD_KG_FILE));
27 27
 
28 28
 function __wl_foodkg__load() {
29 29
 
30 30
 	// Autoloader for plugin itself.
31
-	if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
32
-		require __DIR__ . '/vendor/autoload.php';
31
+	if (file_exists(__DIR__.'/vendor/autoload.php')) {
32
+		require __DIR__.'/vendor/autoload.php';
33 33
 	}
34 34
 
35 35
 	$container_builder = new ContainerBuilder();
36
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
37
-	$loader->load( 'services.yml' );
36
+	$loader            = new YamlFileLoader($container_builder, new FileLocator(__DIR__));
37
+	$loader->load('services.yml');
38 38
 	$container_builder->compile();
39 39
 
40
-	$notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
40
+	$notices = $container_builder->get('Wordlift\Modules\Food_Kg\Notices');
41 41
 	$notices->register_hooks();
42 42
 
43 43
 	/**
44 44
 	 * @var Preconditions $preconditions
45 45
 	 */
46
-	$preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
47
-	if ( ! $preconditions->pass() ) {
46
+	$preconditions = $container_builder->get('Wordlift\Modules\Food_Kg\Preconditions');
47
+	if ( ! $preconditions->pass()) {
48 48
 		return;
49 49
 	}
50 50
 
51 51
 	// Meta Box.
52
-	$meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' );
52
+	$meta_box = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Meta_Box');
53 53
 	$meta_box->register_hooks();
54 54
 
55
-	$module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
55
+	$module = $container_builder->get('Wordlift\Modules\Food_Kg\Module');
56 56
 	$module->register_hooks();
57 57
 
58 58
 	/** @var Jsonld $jsonld */
59
-	$jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
59
+	$jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Jsonld');
60 60
 	$jsonld->register_hooks();
61 61
 
62 62
 	/**
63 63
 	 * Ingredients API.
64 64
 	 */
65
-	$ingredients_api = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_API' );
65
+	$ingredients_api = $container_builder->get('Wordlift\Modules\Food_Kg\Ingredients_API');
66 66
 	$ingredients_api->register_hooks();
67 67
 
68 68
 	/** @var Main_Ingredient_Jsonld $jsonld */
69
-	$main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
69
+	$main_ingredient_jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld');
70 70
 	$main_ingredient_jsonld->register_hooks();
71 71
 
72 72
 	// Main Ingredient Background Task.
73
-	$main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' );
73
+	$main_ingredient_recipe_lift = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy');
74 74
 	Background_Task_Factory::create_action_scheduler_task(
75 75
 		'wl_main_ingredient_sync',
76 76
 		'wordlift',
77 77
 		new All_Posts_Task(
78
-			array( $main_ingredient_recipe_lift, 'process' ),
78
+			array($main_ingredient_recipe_lift, 'process'),
79 79
 			'wprm_recipe',
80 80
 			'sync-main-ingredient'
81 81
 		),
82 82
 		'/main-ingredient',
83 83
 		'sync-main-ingredient',
84
-		__( 'Synchronize Main Ingredient', 'wordlift' )
84
+		__('Synchronize Main Ingredient', 'wordlift')
85 85
 	);
86 86
 
87 87
 	// Ingredients Taxonomy Background Task.
88
-	$ingredients_taxonomy_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy' );
88
+	$ingredients_taxonomy_recipe_lift = $container_builder->get('Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy');
89 89
 	Background_Task_Factory::create(
90 90
 		new Single_Call_Task(
91
-			array( $ingredients_taxonomy_recipe_lift, 'run' ),
91
+			array($ingredients_taxonomy_recipe_lift, 'run'),
92 92
 			'sync-ingredients-taxonomy'
93 93
 		),
94 94
 		'/sync-ingredients-taxonomy',
95 95
 		'sync-ingredients-taxonomy',
96
-		__( 'Synchronize Ingredients Taxonomy', 'wordlift' )
96
+		__('Synchronize Ingredients Taxonomy', 'wordlift')
97 97
 	);
98 98
 
99
-	if ( is_admin() ) {
100
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
99
+	if (is_admin()) {
100
+		$page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Page');
101 101
 		$page->register_hooks();
102 102
 
103
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page' );
103
+		$page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page');
104 104
 		$page->register_hooks();
105 105
 
106 106
 		// Download Ingredients Data.
107
-		$download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' );
107
+		$download_ingredients_data = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data');
108 108
 		$download_ingredients_data->register_hooks();
109 109
 	}
110 110
 }
111 111
 
112
-add_action( 'plugins_loaded', '__wl_foodkg__load' );
112
+add_action('plugins_loaded', '__wl_foodkg__load');
113 113
 
Please login to merge, or discard this patch.
src/wordlift/task/action-scheduler/class-context.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @param $started
16 16
 	 * @param $updated
17 17
 	 */
18
-	public function __construct( $count, $offset, $started, $updated ) {
18
+	public function __construct($count, $offset, $started, $updated) {
19 19
 		$this->count   = $count;
20 20
 		$this->offset  = $offset;
21 21
 		$this->started = $started;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @return Context
36 36
 	 */
37
-	public function set_count( $count ) {
37
+	public function set_count($count) {
38 38
 		$this->count = $count;
39 39
 
40 40
 		return $this;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return Context
54 54
 	 */
55
-	public function set_offset( $offset ) {
55
+	public function set_offset($offset) {
56 56
 		$this->offset = $offset;
57 57
 
58 58
 		return $this;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return Context
72 72
 	 */
73
-	public function set_started( $started ) {
73
+	public function set_started($started) {
74 74
 		$this->started = $started;
75 75
 
76 76
 		return $this;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return Context
90 90
 	 */
91
-	public function set_updated( $updated ) {
91
+	public function set_updated($updated) {
92 92
 		$this->updated = $updated;
93 93
 
94 94
 		return $this;
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return Context
111 111
 	 */
112
-	public static function from( $count ) {
113
-		return new self( $count, 0, time(), time() );
112
+	public static function from($count) {
113
+		return new self($count, 0, time(), time());
114 114
 	}
115 115
 
116 116
 	/**
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return Context
120 120
 	 */
121
-	public static function from_data( $data ) {
122
-		return new self( $data['count'], $data['offset'], $data['started'], $data['updated'] );
121
+	public static function from_data($data) {
122
+		return new self($data['count'], $data['offset'], $data['started'], $data['updated']);
123 123
 	}
124 124
 
125 125
 }
Please login to merge, or discard this patch.
src/wordlift/task/background/class-background-task-route.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	private $route_name;
22 22
 
23
-	public function __construct( $background_task, $route_name ) {
23
+	public function __construct($background_task, $route_name) {
24 24
 		$this->background_task = $background_task;
25 25
 		$this->route_name      = $route_name;
26 26
 	}
27 27
 
28
-	public static function create( $task, $route_name ) {
29
-		$route = new self( $task, $route_name );
28
+	public static function create($task, $route_name) {
29
+		$route = new self($task, $route_name);
30 30
 
31
-		add_action( 'rest_api_init', array( $route, 'register' ) );
31
+		add_action('rest_api_init', array($route, 'register'));
32 32
 
33 33
 		return $route;
34 34
 	}
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 	 * @throws Exception if the input value is invalid.
38 38
 	 */
39 39
 	public function register() {
40
-		Assertions::starts_with( $this->route_name, '/', 'The route name must start with a slash.' );
40
+		Assertions::starts_with($this->route_name, '/', 'The route name must start with a slash.');
41 41
 
42 42
 		register_rest_route(
43 43
 			self::VERSION_STRING,
44 44
 			$this->route_name,
45 45
 			array(
46 46
 				'methods'             => WP_REST_Server::CREATABLE,
47
-				'callback'            => function () {
47
+				'callback'            => function() {
48 48
 					return $this->background_task->start();
49 49
 				},
50
-				'permission_callback' => array( $this, 'permission_callback' ),
50
+				'permission_callback' => array($this, 'permission_callback'),
51 51
 			)
52 52
 		);
53 53
 
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 			$this->route_name,
57 57
 			array(
58 58
 				'methods'             => WP_REST_Server::READABLE,
59
-				'callback'            => function () {
59
+				'callback'            => function() {
60 60
 					return $this->background_task->get_info();
61 61
 				},
62
-				'permission_callback' => array( $this, 'permission_callback' ),
62
+				'permission_callback' => array($this, 'permission_callback'),
63 63
 			)
64 64
 		);
65 65
 
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 			$this->route_name,
69 69
 			array(
70 70
 				'methods'             => WP_REST_Server::DELETABLE,
71
-				'callback'            => function () {
71
+				'callback'            => function() {
72 72
 					return $this->background_task->stop();
73 73
 				},
74
-				'permission_callback' => array( $this, 'permission_callback' ),
74
+				'permission_callback' => array($this, 'permission_callback'),
75 75
 			)
76 76
 		);
77 77
 
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			$this->route_name,
81 81
 			array(
82 82
 				'methods'             => 'PUT',
83
-				'callback'            => function () {
83
+				'callback'            => function() {
84 84
 					return $this->background_task->resume();
85 85
 				},
86
-				'permission_callback' => array( $this, 'permission_callback' ),
86
+				'permission_callback' => array($this, 'permission_callback'),
87 87
 			)
88 88
 		);
89 89
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	public function permission_callback() {
93 93
 		$user = wp_get_current_user();
94 94
 
95
-		return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
95
+		return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles, true);
96 96
 	}
97 97
 
98 98
 	public function get_rest_path() {
99
-		return self::VERSION_STRING . $this->route_name;
99
+		return self::VERSION_STRING.$this->route_name;
100 100
 	}
101 101
 
102 102
 }
Please login to merge, or discard this patch.
src/wordlift/task/background/class-background-task-factory.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	 * @return void
26 26
 	 * @throws Exception in case of invalid arguments.
27 27
 	 */
28
-	public static function create( $task, $route, $page_id, $page_title ) {
29
-		self::assertions( $task, $route );
30
-		$background_task       = Background_Task::create( $task );
31
-		$background_task_route = Background_Task_Route::create( $background_task, $route );
32
-		Background_Task_Page::create( $page_title, $page_id, $background_task_route );
28
+	public static function create($task, $route, $page_id, $page_title) {
29
+		self::assertions($task, $route);
30
+		$background_task       = Background_Task::create($task);
31
+		$background_task_route = Background_Task_Route::create($background_task, $route);
32
+		Background_Task_Page::create($page_title, $page_id, $background_task_route);
33 33
 	}
34 34
 
35 35
 	/**
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 	 * @return void
44 44
 	 * @throws Exception in case of invalid arguments.
45 45
 	 */
46
-	public static function create_action_scheduler_task( $hook, $group, $task, $route, $page_id, $page_title, $batch_size = 5 ) {
47
-		self::assertions( $task, $route );
48
-		$background_task       = new \Wordlift\Task\Action_Scheduler\Background_Task(
46
+	public static function create_action_scheduler_task($hook, $group, $task, $route, $page_id, $page_title, $batch_size = 5) {
47
+		self::assertions($task, $route);
48
+		$background_task = new \Wordlift\Task\Action_Scheduler\Background_Task(
49 49
 			$hook,
50 50
 			$group,
51 51
 			$task,
52 52
 			"_{$hook}_",
53 53
 			$batch_size
54 54
 		);
55
-		$background_task_route = Background_Task_Route::create( $background_task, $route );
56
-		Background_Task_Page::create( $page_title, $page_id, $background_task_route );
55
+		$background_task_route = Background_Task_Route::create($background_task, $route);
56
+		Background_Task_Page::create($page_title, $page_id, $background_task_route);
57 57
 	}
58 58
 
59 59
 	/**
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 * @return void
64 64
 	 * @throws Exception in case of invalid arguments.
65 65
 	 */
66
-	private static function assertions( Task $task, $route ) {
67
-		Assertions::is_a( $task, 'Wordlift\Task\Task' );
68
-		Assertions::starts_with( $route, '/', __( 'The route must start with a slash.', 'wordlift' ) );
66
+	private static function assertions(Task $task, $route) {
67
+		Assertions::is_a($task, 'Wordlift\Task\Task');
68
+		Assertions::starts_with($route, '/', __('The route must start with a slash.', 'wordlift'));
69 69
 	}
70 70
 
71 71
 }
Please login to merge, or discard this patch.
src/wordlift/task/action-scheduler/class-background-task.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	private $batch_size;
28 28
 
29
-	public function __construct( $hook, $group, $task, $option_prefix, $batch_size = 5 ) {
30
-		parent::__construct( $hook, $group );
29
+	public function __construct($hook, $group, $task, $option_prefix, $batch_size = 5) {
30
+		parent::__construct($hook, $group);
31 31
 		$this->task          = $task;
32 32
 		$this->option_prefix = $option_prefix;
33 33
 		$this->batch_size    = $batch_size;
34 34
 	}
35 35
 
36 36
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
37
-	public function do_task( $args ) {
38
-		if ( self::STATE_STOPPED === $this->get_process_state() ) {
37
+	public function do_task($args) {
38
+		if (self::STATE_STOPPED === $this->get_process_state()) {
39 39
 			return State::complete();
40 40
 		}
41 41
 		$context = $this->get_context();
42
-		$this->task->tick( null, $context->get_data() + array( 'batch_size' => $this->batch_size ) );
42
+		$this->task->tick(null, $context->get_data() + array('batch_size' => $this->batch_size));
43 43
 
44
-		if ( ( $context->get_count() - $context->get_offset() ) >= 0 ) {
45
-			$context->set_offset( $context->get_offset() + $this->batch_size )->set_updated( time() );
46
-			$this->set_info( $context );
44
+		if (($context->get_count() - $context->get_offset()) >= 0) {
45
+			$context->set_offset($context->get_offset() + $this->batch_size)->set_updated(time());
46
+			$this->set_info($context);
47 47
 			return State::items_in_queue();
48 48
 		} else {
49
-			$this->set_process_state( self::STATE_STOPPED );
49
+			$this->set_process_state(self::STATE_STOPPED);
50 50
 			return State::complete();
51 51
 		}
52 52
 
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 
55 55
 	public function start() {
56 56
 		$this->delete_info();
57
-		$this->set_process_state( self::STATE_STARTED );
57
+		$this->set_process_state(self::STATE_STARTED);
58 58
 		$this->schedule();
59 59
 	}
60 60
 
61 61
 	public function stop() {
62
-		$this->set_process_state( self::STATE_STOPPED );
62
+		$this->set_process_state(self::STATE_STOPPED);
63 63
 		$this->unschedule();
64 64
 	}
65 65
 
66 66
 	public function resume() {
67
-		$this->set_process_state( self::STATE_STARTED );
67
+		$this->set_process_state(self::STATE_STARTED);
68 68
 		$this->schedule();
69 69
 	}
70 70
 
71 71
 	public function get_info() {
72
-		return $this->get_context()->get_data() + array( 'state' => $this->get_process_state() );
72
+		return $this->get_context()->get_data() + array('state' => $this->get_process_state());
73 73
 	}
74 74
 
75 75
 	public function get_context() {
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 			null
79 79
 		);
80 80
 
81
-		if ( null === $data ) {
82
-			return Context::from( (int) $this->task->starting() );
81
+		if (null === $data) {
82
+			return Context::from((int) $this->task->starting());
83 83
 		}
84 84
 
85
-		return Context::from_data( $data );
85
+		return Context::from_data($data);
86 86
 	}
87 87
 
88 88
 	/**
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return void
92 92
 	 */
93
-	public function set_info( $context ) {
94
-		update_option( "{$this->option_prefix}_state", $context->get_data() );
93
+	public function set_info($context) {
94
+		update_option("{$this->option_prefix}_state", $context->get_data());
95 95
 	}
96 96
 
97 97
 	private function delete_info() {
98
-		delete_option( "{$this->option_prefix}_state" );
98
+		delete_option("{$this->option_prefix}_state");
99 99
 	}
100 100
 
101 101
 	private function get_process_state() {
102
-		return get_option( "{$this->option_prefix}_action_scheduler_state", self::STATE_STOPPED );
102
+		return get_option("{$this->option_prefix}_action_scheduler_state", self::STATE_STOPPED);
103 103
 	}
104 104
 
105
-	private function set_process_state( $state ) {
106
-		update_option( "{$this->option_prefix}_action_scheduler_state", $state );
105
+	private function set_process_state($state) {
106
+		update_option("{$this->option_prefix}_action_scheduler_state", $state);
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.