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

SnapshotConfiguration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A getSteps() 0 3 1
A getSnapshotClass() 0 3 1
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