Skip to content

Instantly share code, notes, and snippets.

@johnnyfreeman
Created July 27, 2012 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnyfreeman/3189215 to your computer and use it in GitHub Desktop.
Save johnnyfreeman/3189215 to your computer and use it in GitHub Desktop.
Article: Method Chaining in PHP
<?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