Completed
Pull Request — develop (#1328)
by Naveen
03:00
created

Sync_State::unknown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Vocabulary;
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( $count ) {
31
		$this->index       += $count;
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 function get_array() {
45
		return array(
46
			'started'     => $this->started,
47
			'index'       => $this->index,
48
			'count'       => $this->count,
49
			'last_update' => $this->last_update,
50
			'state'       => $this->state
51
		);
52
	}
53
54
	public static function unknown() {
55
56
		return new self( time(), 0, 0, time(), 'unknown' );
57
	}
58
59
}