1 <?php
2 /* --------------------------------------------------------------
3 AttachmentName.php 2015-05-12 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('AttachmentNameInterface');
13
14 /**
15 * Class AttachmentName
16 *
17 * Important: This value object is not going to check if the attachment file exists in the
18 * server because that would cause problems with the service usage (e.g. if an attachment
19 * file is missing an exception would halt all the email service operations).
20 *
21 * @category System
22 * @package Email
23 * @subpackage ValueObjects
24 */
25 class AttachmentName implements AttachmentNameInterface
26 {
27
28 /**
29 * Email attachment name.
30 *
31 * @var string
32 */
33 protected $name;
34
35
36 /**
37 * Constructor
38 *
39 * Executes the validation checks for the email attachment.
40 *
41 * @param string $p_name E-Mail attachment name.
42 * @throws InvalidArgumentException On invalid argument.
43 */
44 public function __construct($p_name)
45 {
46 if(!is_string($p_name))
47 {
48 throw new InvalidArgumentException('Invalid argument provided (expected string name) $p_emailAttachment: '
49 . print_r($p_name, true));
50 }
51
52 $this->name = $p_name;
53 }
54
55
56 /**
57 * Returns the attachment path.
58 *
59 * @return string Equivalent string.
60 */
61 public function __toString()
62 {
63 return $this->name;
64 }
65 }