Completed
Push — master ( 33591a...530541 )
by Freek
09:49
created

CouldNotCreateSnapshot   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A projectorDidNotWriteAnythingToSnapshot() 0 4 1
A projectorThrewExceptionDuringWritingToSnapshot() 0 4 1
A newEventsStoredDuringSnapshotCreation() 0 4 1
1
<?php
2
3
namespace Spatie\EventProjector\Exceptions;
4
5
use Exception;
6
use Illuminate\Support\Collection;
7
use Spatie\EventProjector\Projectors\Projector;
8
use Spatie\EventProjector\Snapshots\Snapshot;
9
10
class CouldNotCreateSnapshot extends Exception
11
{
12
    public static function projectorDidNotWriteAnythingToSnapshot(Projector $projector)
13
    {
14
        return new static("The projector named {$projector->getName()} didn't write to the snapshot. When snapshotting a projector should write it's state to the snapshot.");
15
    }
16
17
    public static function projectorThrewExceptionDuringWritingToSnapshot(Projector $projector, Exception $exception)
18
    {
19
        return new static("The projector named {$projector->getName()} threw an exception while writing to a snapshot", 0, $exception);
20
    }
21
22
    public static function newEventsStoredDuringSnapshotCreation(Snapshot $snapshot, Collection $newEventsHandledByProjectorOfSnapshot)
0 ignored issues
show
Unused Code introduced by
The parameter $newEventsHandledByProjectorOfSnapshot is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        return new static("While creating a snapshot for projector `{$snapshot->name()}` new events were stored where the projector listens for. The validity of the snapshot could not be guarantied so it was deleted. Try creating the snapshot again.");
25
    }
26
}
27