Last active
August 29, 2015 14:22
-
-
Save alanwillms/203b6a966c1d9546c48e to your computer and use it in GitHub Desktop.
Exemplo de método com múltiplas responsabilidades, violando SRP
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 Notificacao | |
| { | |
| /** | |
| * Envia esta notificação por e-mail se o destinatário for válido. | |
| * @return boolean se a mensagem foi enviada com sucesso. | |
| */ | |
| public function enviar() | |
| { | |
| if (!$this->destinatario || !preg_match(EMAIL_REGEX, $this->destinatario)) { | |
| return false; | |
| } | |
| $mensagem = $this->mensagem . "\n\Enviada por ACME® Messenger"; | |
| return mail($this->destinatario, $this->assunto, $mensagem); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment