Passed
Push — master ( 01de3e...63efc4 )
by Blixit
01:54
created

SnapshotConfiguration::getSnapshotClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Blixit\EventSourcing\Store\SnapshotStore;
6
7
use Exception;
8
9
class SnapshotConfiguration
10
{
11
    /**
12
     * The number of events between each snapshot
13
     *
14
     * @var int $steps
15
     */
16
    private $steps;
17
18
    /**
19
     * The snapshot class to instantiante when storing the snapshot objects
20
     *
21
     * @var string $snapshotClass
22
     */
23
    private $snapshotClass;
24
25
    /**
26
     * @throws Exception
27
     */
28
    public function __construct(int $steps, string $snapshotClass)
29
    {
30
        if ($steps <= 0) {
31
            throw new Exception('The snapshot step should be greater than 0');
32
        }
33
        $this->snapshotClass = empty($snapshotClass) ? Snapshot::class : $snapshotClass;
34
        $this->steps         = $steps;
35
    }
36
37
    public function getSteps() : int
38
    {
39
        return $this->steps;
40
    }
41
42
    public function getSnapshotClass() : string
43
    {
44
        return $this->snapshotClass;
45
    }
46
}
47