forked from sendgrid/sendgrid-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SendGrid.php
42 lines (33 loc) · 859 Bytes
/
SendGrid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
class SendGrid
{
protected $namespace = "SendGrid",
$username,
$password;
// Available transport mechanisms
protected $web,
$smtp;
public function __construct($username, $password)
{
$this->username = $username;
$this->password = $password;
}
public function __get($api)
{
$name = $api;
if($this->$name != null)
{
return $this->$name;
}
$api = $this->namespace . "\\" . ucwords($api);
$class_name = str_replace('\\', '/', "$api.php");
$file = __dir__ . DIRECTORY_SEPARATOR . $class_name;
if (!file_exists($file))
{
throw new Exception("Api '$class_name' not found.");
}
require_once $file;
$this->$name = new $api($this->username, $this->password);
return $this->$name;
}
}