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