Completed
Push — develop ( 1d2391...a94b56 )
by David
02:55 queued 11s
created

Sync_State::increment_index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Dataset;
4
5
class Sync_State {
6
7
	public $started;
8
	public $index;
9
	public $count;
10
	public $last_update;
11
	public $state;
12
13
	/**
14
	 * Sync_Model constructor.
15
	 *
16
	 * @param $started
17
	 * @param $index
18
	 * @param $count
19
	 * @param $last_update
20
	 * @param $state
21
	 */
22
	public function __construct( $started, $index, $count, $last_update, $state ) {
23
		$this->started     = $started;
24
		$this->index       = $index;
25
		$this->count       = (int) $count;
26
		$this->last_update = $last_update;
27
		$this->state       = $state;
28
	}
29
30
	public function increment_index() {
31
		$this->index ++;
32
		$this->last_update = time();
33
34
		return $this;
35
	}
36
37
	public function set_state( $value ) {
38
		$this->state       = $value;
39
		$this->last_update = time();
40
41
		return $this;
42
	}
43
44
	public static function unknown() {
45
46
		return new self( time(), 0, 0, time(), 'unknown' );
47
	}
48
49
}