Skip to content

Instantly share code, notes, and snippets.

@MacDada
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MacDada/f60b59c12ee7bcc5c1b9 to your computer and use it in GitHub Desktop.
Save MacDada/f60b59c12ee7bcc5c1b9 to your computer and use it in GitHub Desktop.
<?php
class BackupManager
{
public function __construct($configOption1, $configOption2);
public function create(Entity $entity);
public function restore(Entity $entity);
public function remove(Entity $entity);
}
<?php
class Command
{
public function __construct(BackupManager $backupManager);
public function run(Entity $entity)
{
$this->backupManager->create($entity);
try {
// work with $entity
} catch (Exception $e) {
$this->backupManager->restore($entity);
}
$this->backupManager->remove($entity);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment