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;
const OFF = false;
const ON = true;
/**
* @var bool
*/
private $state = self::OFF;
* @return bool
private function createSnapshotState()
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 = $state;
return $lightSwitch;
This check looks for private methods that have been defined, but are not used inside the class.