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