1 <?php
2 /* --------------------------------------------------------------
3 EmailContent.inc.php 2015-01-29 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('EmailContentInterface');
13
14 /**
15 * Class EmailContent
16 *
17 * Email content could be either plain text or HTML.
18 *
19 * @category System
20 * @package Email
21 * @subpackage ValueObjects
22 */
23 class EmailContent implements EmailContentInterface
24 {
25 /**
26 * E-Mail content.
27 * @var string Email Content
28 */
29 protected $content;
30
31
32 /**
33 * Constructor
34 *
35 * Executes the validation checks upon the email content.
36 *
37 * @param string $p_content Could be either plain text or HTML.
38 * @throws InvalidArgumentException On invalid argument.
39 */
40 public function __construct($p_content)
41 {
42 if(!is_string($p_content))
43 {
44 throw new InvalidArgumentException('Invalid argument provided (expected string content) $p_content: '
45 . print_r($p_content, true));
46 }
47
48 $this->content = $p_content;
49 }
50
51
52 /**
53 * Returns the email content value.
54 *
55 * @return string Equivalent string.
56 */
57 public function __toString()
58 {
59 return $this->content;
60 }
61 }