| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCommunity\App\Services; |
| 4 |
|
| 5 |
class EmailDomBuilder |
| 6 |
{ |
| 7 |
protected $config = []; |
| 8 |
|
| 9 |
protected $elements = []; |
| 10 |
|
| 11 |
public function __construct($config = []) |
| 12 |
{ |
| 13 |
$defaults = [ |
| 14 |
'font_size' => '14px', |
| 15 |
'font_family' => 'Arial, Helvetica, sans-serif', |
| 16 |
]; |
| 17 |
|
| 18 |
$this->config = $config; |
| 19 |
} |
| 20 |
|
| 21 |
public function line($content, $tag = 'p') |
| 22 |
{ |
| 23 |
$this->elements[] = [ |
| 24 |
'type' => 'line', |
| 25 |
'tag' => $tag, |
| 26 |
'content' => $content, |
| 27 |
]; |
| 28 |
return $this; |
| 29 |
} |
| 30 |
|
| 31 |
public function heading($content, $tag = 'h2') |
| 32 |
{ |
| 33 |
$this->elements[] = [ |
| 34 |
'type' => 'heading', |
| 35 |
'tag' => $tag, |
| 36 |
'content' => $content, |
| 37 |
]; |
| 38 |
return $this; |
| 39 |
} |
| 40 |
|
| 41 |
public function button($url, $btnText, $style = 'primary') |
| 42 |
{ |
| 43 |
$this->elements[] = [ |
| 44 |
'type' => 'button', |
| 45 |
'content' => $btnText, |
| 46 |
'url' => $url, |
| 47 |
'style' => $style |
| 48 |
]; |
| 49 |
return $this; |
| 50 |
} |
| 51 |
|
| 52 |
public function url($url, $content) |
| 53 |
{ |
| 54 |
$this->elements[] = [ |
| 55 |
'type' => 'url', |
| 56 |
'content' => $content, |
| 57 |
'url' => $url, |
| 58 |
]; |
| 59 |
return $this; |
| 60 |
} |
| 61 |
|
| 62 |
public function image($imageUrl, $alt = '') |
| 63 |
{ |
| 64 |
$this->elements[] = [ |
| 65 |
'type' => 'image', |
| 66 |
'content' => $imageUrl, |
| 67 |
'alt' => $alt, |
| 68 |
]; |
| 69 |
return $this; |
| 70 |
} |
| 71 |
|
| 72 |
} |
| 73 |
|