Skip to content

Instantly share code, notes, and snippets.

@assertchris
Created August 21, 2015 20:13
Show Gist options
  • Save assertchris/eb1e01653a3a20a69355 to your computer and use it in GitHub Desktop.
Save assertchris/eb1e01653a3a20a69355 to your computer and use it in GitHub Desktop.
<?php
interface Task
{
/**
* @return bool
*/
public function shouldLog();
}
class EmailTask implements Task
{
public function shouldLog()
{
return false;
}
}
$handler->handle(new EmailTask()); // no logging
// then you want to debug a problem. With that classes structure, you could...
$handler->handle(new class extends EmailTask {
public function shouldLog()
{
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment