Completed
Push — develop ( 88fa56...72a91d )
by
unknown
39s queued 12s
created

Abstract_Sync_Background_Process_State::resume()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Dataset\Background;
4
5
abstract class Abstract_Sync_Background_Process_State implements Sync_Background_Process_State {
6
7
	private $state;
8
9
	function __construct( $state ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
10
		$this->state = $state;
11
	}
12
13
	function get_info() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
		$started     = get_option( '_wl_sync_background_process_started' );
15
		$offset      = get_option( '_wl_sync_background_process_offset' );
16
		$stage       = get_option( '_wl_sync_background_process_stage' );
17
		$counts      = get_option( '_wl_sync_background_process_count', array( 0 ) );
18
		$last_update = get_option( '_wl_sync_background_process_updated' );
19
20
		// Calculate the overall index by adding the count of completed stages.
21
		$index = $offset + 1;
22
		for ( $i = 0; $i < $stage; $i ++ ) {
23
			$index += $counts[ $i ];
24
		}
25
26
		// Get the total count.
27
		$total_count = array_sum( $counts );
28
29
		return new Sync_Background_Process_Info( $this->state, $started, $index, $total_count, $last_update );
30
	}
31
32
	function resume() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
		// do nothing.
34
	}
35
36
}
37