Skip to content
Snippets Groups Projects
Unverified Commit fd9bf496 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

PSR-2 + phpdoc

parent a8f60543
No related branches found
No related tags found
No related merge requests found
......@@ -6,22 +6,22 @@
* @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @package SimpleSAMLphp
*/
class SimpleSAML_XHTML_EMail {
private $to = NULL;
private $cc = NULL;
private $body = NULL;
private $from = NULL;
private $replyto = NULL;
private $subject = NULL;
class SimpleSAML_XHTML_EMail
{
private $to = null;
private $cc = null;
private $body = null;
private $from = null;
private $replyto = null;
private $subject = null;
private $headers = array();
/**
* Constructor
*/
function __construct($to, $subject, $from = NULL, $cc = NULL, $replyto = NULL) {
public function __construct($to, $subject, $from = null, $cc = null, $replyto = null)
{
$this->to = $to;
$this->cc = $cc;
$this->from = $from;
......@@ -29,10 +29,20 @@ class SimpleSAML_XHTML_EMail {
$this->subject = $subject;
}
function setBody($body) {
/*
* @param string $body
* @return void
*/
public function setBody($body)
{
$this->body = $body;
}
/*
* @param string $body
* @return void
*/
private function getHTML($body) {
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
......@@ -60,10 +70,19 @@ pre {
</html>';
}
function send() {
if ($this->to == NULL) throw new Exception('EMail field [to] is required and not set.');
if ($this->subject == NULL) throw new Exception('EMail field [subject] is required and not set.');
if ($this->body == NULL) throw new Exception('EMail field [body] is required and not set.');
/*
* @return void
*/
public function send()
{
if ($this->to === null) {
throw new Exception('EMail field [to] is required and not set.');
} elseif ($this->subject === null) {
throw new Exception('EMail field [subject] is required and not set.');
} elseif ($this->body === null) {
throw new Exception('EMail field [body] is required and not set.');
}
$random_hash = bin2hex(openssl_random_pseudo_bytes(16));
......@@ -93,7 +112,8 @@ Content-Transfer-Encoding: 8bit
$mail_sent = @mail($this->to, $this->subject, $message, $headers);
SimpleSAML\Logger::debug('Email: Sending e-mail to [' . $this->to . '] : ' . ($mail_sent ? 'OK' : 'Failed'));
if (!$mail_sent) throw new Exception('Error when sending e-mail');
if (!$mail_sent) {
throw new Exception('Error when sending e-mail');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment