Last active
August 21, 2018 11:26
-
-
Save JeroenDeDauw/b0558444a107d642ee99c40bc2cc9daf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface EntityRevisionLookup { | |
public function getLatestRevisionId( EntityId $entityId, RevisionLookupResultHandler $resultHandler ): void; | |
} | |
// Interface version | |
// Great if you have anonymous classes | |
interface RevisionLookupResultHandler { | |
public function notFound(); | |
public function redirectFound( int $redirectId, int $entityId ); | |
public function entityFound( int $entityId ); | |
} | |
// Callback version | |
class RevisionLookupResultHandler { | |
// Possibly constructed via fluent interface instead | |
public function __construct( callable $onNotFound, callable $onRedirectFound, callable $onFound ) {} | |
public function invokeOnNotFound() { | |
($this->onNotFound)(); | |
} | |
public function invokeRedirectFound( int $redirectId, int $entityId ) { | |
($this->onRedirectFound)( $redirectId, $entityId ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment