Created
August 21, 2015 20:13
-
-
Save assertchris/eb1e01653a3a20a69355 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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