Completed
Push — master ( e610ee...c79300 )
by Arne
04:09
created

Synchronization::fromScalarArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace Storeman;
4
5
use Storeman\Index\Index;
6
7
/**
8
 * As the name suggests this class represents the synchronization for a specific revision.
9
 */
10
class Synchronization
11
{
12
    /**
13
     * @var int
14
     */
15
    protected $revision;
16
17
    /**
18
     * @var \DateTime
19
     */
20
    protected $time;
21
22
    /**
23
     * @var string
24
     */
25
    protected $identity;
26
27
    /**
28
     * @var Index
29
     */
30
    protected $index;
31
32
    public function __construct(int $revision, \DateTime $time, string $identity, Index $index = null)
33
    {
34
        $this->revision = $revision;
35
        $this->time = $time;
36
        $this->identity = $identity;
37
        $this->index = $index;
38
    }
39
40
    public function getRevision(): int
41
    {
42
        return $this->revision;
43
    }
44
45
    public function getTime(): \DateTime
46
    {
47
        return $this->time;
48
    }
49
50
    public function getIdentity(): string
51
    {
52
        return $this->identity;
53
    }
54
55
    public function getIndex(): ?Index
56
    {
57
        return $this->index;
58
    }
59
60
    public function setIndex(Index $index): Synchronization
61
    {
62
        assert($this->index === null);
63
64
        $this->index = $index;
65
66
        return $this;
67
    }
68
}
69