Created
July 27, 2012 17:15
-
-
Save johnnyfreeman/3189215 to your computer and use it in GitHub Desktop.
Article: Method Chaining in PHP
This file contains 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 Email extends BaseEmail { | |
protected $to = ''; | |
protected $subject = '' | |
protected $message = ''; | |
public function to($email) | |
{ | |
$this->to = $email; | |
return $this; | |
} | |
public function subject($subject) | |
{ | |
$this->subject = $subject; | |
return $this; | |
} | |
public function message($message) | |
{ | |
$this->message = $message; | |
return $this; | |
} | |
public function send() | |
{ | |
return mail($this->to, $this->subject, $this->message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment