|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Eluceo\iCal\Component; |
|
|
|
use Eluceo\iCal\Component; |
|
use Eluceo\iCal\Property\Event\RecurrenceRule; |
|
use Eluceo\iCal\PropertyBag; |
|
|
|
|
|
|
|
|
|
|
|
class TimezoneRule extends Component |
|
{ |
|
const TYPE_DAYLIGHT = 'DAYLIGHT'; |
|
const TYPE_STANDARD = 'STANDARD'; |
|
|
|
|
|
|
|
|
|
protected $type; |
|
|
|
|
|
|
|
|
|
protected $tzOffsetFrom; |
|
|
|
|
|
|
|
|
|
protected $tzOffsetTo; |
|
|
|
|
|
|
|
|
|
protected $tzName; |
|
|
|
|
|
|
|
|
|
protected $dtStart; |
|
|
|
|
|
|
|
|
|
protected $recurrenceRule; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct($ruleType) |
|
{ |
|
$ruleType = strtoupper($ruleType); |
|
if ($ruleType === self::TYPE_DAYLIGHT || $ruleType === self::TYPE_STANDARD) { |
|
$this->type = $ruleType; |
|
} else { |
|
throw new \InvalidArgumentException('Invalid value for timezone rule type'); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
public function buildPropertyBag() |
|
{ |
|
$propertyBag = new PropertyBag(); |
|
|
|
if ($this->getTzName()) { |
|
$propertyBag->set('TZNAME', $this->getTzName()); |
|
} |
|
|
|
if ($this->getTzOffsetFrom()) { |
|
$propertyBag->set('TZOFFSETFROM', $this->getTzOffsetFrom()); |
|
} |
|
|
|
if ($this->getTzOffsetTo()) { |
|
$propertyBag->set('TZOFFSETTO', $this->getTzOffsetTo()); |
|
} |
|
|
|
if ($this->getDtStart()) { |
|
$propertyBag->set('DTSTART', $this->getDtStart()); |
|
} |
|
|
|
if ($this->recurrenceRule) { |
|
$propertyBag->set('RRULE', $this->recurrenceRule); |
|
} |
|
|
|
return $propertyBag; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setTzOffsetFrom($offset) |
|
{ |
|
$this->tzOffsetFrom = $offset; |
|
|
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setTzOffsetTo($offset) |
|
{ |
|
$this->tzOffsetTo = $offset; |
|
|
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setTzName($name) |
|
{ |
|
$this->tzName = $name; |
|
|
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
public function setDtStart(\DateTimeInterface $dtStart) |
|
{ |
|
$this->dtStart = $dtStart; |
|
|
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
public function setRecurrenceRule(RecurrenceRule $recurrenceRule) |
|
{ |
|
$this->recurrenceRule = $recurrenceRule; |
|
|
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
public function getType() |
|
{ |
|
return $this->type; |
|
} |
|
|
|
|
|
|
|
|
|
public function getTzOffsetFrom() |
|
{ |
|
return $this->tzOffsetFrom; |
|
} |
|
|
|
|
|
|
|
|
|
public function getTzOffsetTo() |
|
{ |
|
return $this->tzOffsetTo; |
|
} |
|
|
|
|
|
|
|
|
|
public function getTzName() |
|
{ |
|
return $this->tzName; |
|
} |
|
|
|
|
|
|
|
|
|
public function getRecurrenceRule() |
|
{ |
|
return $this->recurrenceRule; |
|
} |
|
|
|
|
|
|
|
|
|
public function getDtStart() |
|
{ |
|
if ($this->dtStart) { |
|
return $this->dtStart->format('Ymd\THis'); |
|
} |
|
|
|
return; |
|
} |
|
} |
|
|