for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace EventSauce\EventSourcing\Snapshotting\Tests;
use EventSauce\EventSourcing\AggregateRootBehaviour;
use EventSauce\EventSourcing\AggregateRootId;
use EventSauce\EventSourcing\Snapshotting\AggregateRootWithSnapshotting;
use EventSauce\EventSourcing\Snapshotting\SnapshottingBehaviour;
final class LightSwitch implements AggregateRootWithSnapshotting
{
use AggregateRootBehaviour;
use SnapshottingBehaviour;
public const OFF = false;
public const ON = true;
private bool $state = self::OFF;
private function createSnapshotState(): bool
createSnapshotState()
This check looks for private methods that have been defined, but are not used inside the class.
return $this->state;
}
public function state(): bool
public function turnOn(): void
if (self::OFF == $this->state) {
$this->recordThat(LightSwitchWasFlipped::on());
public function turnOff(): void
if (self::ON == $this->state) {
$this->recordThat(LightSwitchWasFlipped::off());
protected function applyLightSwitchWasFlipped(LightSwitchWasFlipped $event): void
$this->state = $event->state();
/**
* @param bool $state
*/
protected static function reconstituteFromSnapshotState(AggregateRootId $id, $state): AggregateRootWithSnapshotting
$lightSwitch = new static($id);
$lightSwitch->state = (bool) $state;
return $lightSwitch;
This check looks for private methods that have been defined, but are not used inside the class.