1 <?php
2 /* --------------------------------------------------------------
3 AttachmentPath.php 2015-01-30 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('AttachmentPathInterface');
13
14 /**
15 * Class AttachmentPath
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 AttachmentPath implements AttachmentPathInterface
26 {
27 /**
28 * Email attachment path.
29 * @var string
30 */
31 protected $path;
32
33
34 /**
35 * Constructor
36 *
37 * Executes the validation checks for the email attachment.
38 *
39 * @throws InvalidArgumentException If the provided argument is not a string or empty.
40 *
41 * @param string $p_path E-Mail attachment path.
42 */
43 public function __construct($p_path)
44 {
45 if(!is_string($p_path) || empty($p_path))
46 {
47 throw new InvalidArgumentException('Invalid argument provided (expected string path) $p_emailAttachment: '
48 . print_r($p_path, true));
49 }
50
51 $this->path = $p_path;
52 }
53
54
55 /**
56 * Returns attachment path.
57 *
58 * @return string Equivalent string.
59 */
60 public function __toString()
61 {
62 return $this->path;
63 }
64 }