1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the eluceo/iCal package. |
5
|
|
|
* |
6
|
|
|
* (c) Markus Poerschke <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Eluceo\iCal\Property; |
13
|
|
|
|
14
|
|
|
class StringValue implements ValueInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The value. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $value; |
22
|
|
|
|
23
|
67 |
|
public function __construct($value) |
24
|
|
|
{ |
25
|
67 |
|
$this->value = $value; |
26
|
67 |
|
} |
27
|
|
|
|
28
|
44 |
|
public function getEscapedValue(): string |
29
|
|
|
{ |
30
|
44 |
|
$value = $this->value; |
31
|
|
|
|
32
|
44 |
|
$value = str_replace('\\', '\\\\', $value); |
33
|
44 |
|
$value = str_replace('"', '\\"', $value); |
34
|
44 |
|
$value = str_replace(',', '\\,', $value); |
35
|
44 |
|
$value = str_replace(';', '\\;', $value); |
36
|
44 |
|
$value = str_replace("\n", '\\n', $value); |
37
|
44 |
|
$value = str_replace([ |
38
|
44 |
|
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", |
39
|
|
|
"\x08", "\x09", /* \n*/ "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", |
40
|
|
|
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", |
41
|
|
|
"\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F", |
42
|
|
|
"\x7F", |
43
|
44 |
|
], '', $value); |
44
|
|
|
|
45
|
44 |
|
return $value; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $value |
50
|
|
|
* |
51
|
|
|
* @return $this |
52
|
|
|
*/ |
53
|
1 |
|
public function setValue($value) |
54
|
|
|
{ |
55
|
1 |
|
$this->value = $value; |
56
|
|
|
|
57
|
1 |
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
7 |
|
public function getValue() |
64
|
|
|
{ |
65
|
7 |
|
return $this->value; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|