1 <?php
2
3 /* --------------------------------------------------------------
4 StringType.inc.php 2015-11-04 gm
5 Gambio GmbH
6 http://www.gambio.de
7 Copyright (c) 2015 Gambio GmbH
8 Released under the GNU General Public License (Version 2)
9 [http://www.gnu.org/licenses/gpl-2.0.html]
10 --------------------------------------------------------------
11 */
12
13 /**
14 * Class StringType
15 *
16 * Shared string type class. Use the "asString" method for getting the plain value.
17 *
18 * @category System
19 * @package Shared
20 * @subpackage Types
21 */
22 class StringType
23 {
24 /**
25 * Instance Value
26 *
27 * @var string
28 */
29 protected $value;
30
31
32 /**
33 * Class Constructor
34 *
35 * @throws InvalidArgumentException
36 *
37 * @param string $p_value
38 */
39 public function __construct($p_value)
40 {
41 if(!is_string($p_value))
42 {
43 throw new InvalidArgumentException('StringType: Invalid argument value given (expected string got '
44 . gettype($p_value) . '): ' . $p_value);
45 }
46
47 $this->value = $p_value;
48 }
49
50
51 /**
52 * Get the instance value as string.
53 *
54 * @return string
55 */
56 public function asString()
57 {
58 return $this->value;
59 }
60 }