Completed
Push — master ( f8d577...6d4239 )
by Freek
18s queued 11s
created

unexpectedVersionAlreadyPersisted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Spatie\EventSourcing\Exceptions;
4
5
use Exception;
6
use Spatie\EventSourcing\AggregateRoot;
7
8
class CouldNotPersistAggregate extends Exception
9
{
10
    public static function unexpectedVersionAlreadyPersisted(
11
        AggregateRoot $aggregateRoot,
12
        string $uuid,
13
        int $expectedVersion,
14
        int $actualVersion
15
    ) {
16
        $aggregateRootClass = class_basename($aggregateRoot);
17
18
        return new static("Could not persist aggregate {$aggregateRootClass} (uuid: {$uuid}) because it seems to be changed by another process after it was retrieved in the current process. Expect to persist events after version {$expectedVersion}, but version {$actualVersion} was already persisted.");
19
    }
20
}
21