Mercurial > hg > rc1
comparison vendor/sabre/vobject/lib/Property/ICalendar/Duration.php @ 7:430dbd5346f7
vendor sabre as distributed
author | Charlie Root |
---|---|
date | Sat, 13 Jan 2018 09:06:10 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
6:cec75ba50afc | 7:430dbd5346f7 |
---|---|
1 <?php | |
2 | |
3 namespace Sabre\VObject\Property\ICalendar; | |
4 | |
5 use | |
6 Sabre\VObject\Property, | |
7 Sabre\VObject\Parser\MimeDir, | |
8 Sabre\VObject\DateTimeParser; | |
9 | |
10 /** | |
11 * Duration property | |
12 * | |
13 * This object represents DURATION values, as defined here: | |
14 * | |
15 * http://tools.ietf.org/html/rfc5545#section-3.3.6 | |
16 * | |
17 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). | |
18 * @author Evert Pot (http://evertpot.com/) | |
19 * @license http://sabre.io/license/ Modified BSD License | |
20 */ | |
21 class Duration extends Property { | |
22 | |
23 /** | |
24 * In case this is a multi-value property. This string will be used as a | |
25 * delimiter. | |
26 * | |
27 * @var string|null | |
28 */ | |
29 public $delimiter = ','; | |
30 | |
31 /** | |
32 * Sets a raw value coming from a mimedir (iCalendar/vCard) file. | |
33 * | |
34 * This has been 'unfolded', so only 1 line will be passed. Unescaping is | |
35 * not yet done, but parameters are not included. | |
36 * | |
37 * @param string $val | |
38 * @return void | |
39 */ | |
40 public function setRawMimeDirValue($val) { | |
41 | |
42 $this->setValue(explode($this->delimiter, $val)); | |
43 | |
44 } | |
45 | |
46 /** | |
47 * Returns a raw mime-dir representation of the value. | |
48 * | |
49 * @return string | |
50 */ | |
51 public function getRawMimeDirValue() { | |
52 | |
53 return implode($this->delimiter, $this->getParts()); | |
54 | |
55 } | |
56 | |
57 /** | |
58 * Returns the type of value. | |
59 * | |
60 * This corresponds to the VALUE= parameter. Every property also has a | |
61 * 'default' valueType. | |
62 * | |
63 * @return string | |
64 */ | |
65 public function getValueType() { | |
66 | |
67 return 'DURATION'; | |
68 | |
69 } | |
70 | |
71 /** | |
72 * Returns a DateInterval representation of the Duration property. | |
73 * | |
74 * If the property has more than one value, only the first is returned. | |
75 * | |
76 * @return \DateInterval | |
77 */ | |
78 public function getDateInterval() { | |
79 | |
80 $parts = $this->getParts(); | |
81 $value = $parts[0]; | |
82 return DateTimeParser::parseDuration($value); | |
83 | |
84 } | |
85 | |
86 } |