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

CouldNotPersistAggregate   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A unexpectedVersionAlreadyPersisted() 0 10 1
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