Last active
October 2, 2015 19:03
-
-
Save alanwillms/fa8f98acf757981dde28 to your computer and use it in GitHub Desktop.
Null Object (based on an Upcase example)
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 | |
| class AssinaturaGratuita extends Assinatura | |
| { | |
| public function isPremium() | |
| { | |
| return false; | |
| } | |
| public function getValor() | |
| { | |
| return 0; | |
| } | |
| public function cobrar(CartaoCredito $cartao) | |
| { | |
| } | |
| } | |
| // Utilização | |
| if (null === $assinatura) { | |
| $assinatura = new AssinaturaGratuita; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment