public extractAggregateVersion ( object $eventSourcedAggregateRoot ) : integer | ||
$eventSourcedAggregateRoot | object | |
Результат | integer |
public function extractAggregateVersion($eventSourcedAggregateRoot)
{
if (!method_exists($eventSourcedAggregateRoot, $this->versionMethodName)) {
throw new AggregateTranslationFailedException(sprintf('Required method %s does not exist for aggregate %s', $this->versionMethodName, get_class($eventSourcedAggregateRoot)));
}
return (int) $eventSourcedAggregateRoot->{$this->versionMethodName}();
}
/** * @test * @expectedException \Prooph\EventStore\Aggregate\Exception\AggregateTranslationFailedException */ public function it_throws_exception_if_version_method_does_not_exist() { $ar = $this->prophesize(CustomAggregateRootContract::class); $translator = new ConfigurableAggregateTranslator('unknownMethodName'); $translator->extractAggregateVersion($ar->reveal()); }