/** * Adds a Property. If Property already exists an Exception will be thrown. * * @param Property $property * @throws \Exception */ public function add(Property $property) { // Property already exists? if (null !== $this->get($property->getName())) { throw new \Exception("Property with name '{$property->getName()}' already exists"); } $this->elements[] = $property; }
/** * @param string $name * @param \DateTime[] $dateTimes * @param bool $noTime * @param bool $useTimezone * @param bool $useUtc */ public function __construct($name, $dateTimes = array(), $noTime = false, $useTimezone = false, $useUtc = false) { $dates = array(); foreach ($dateTimes as $dateTime) { $dates[] = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc); } $params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone); parent::__construct($name, $dates, $params); }
/** * @param string $name * @param \DateTime $dateTime * @param bool $noTime * @param bool $useTimezone * @param bool $useUtc */ function __construct($name, \DateTime $dateTime = null, $noTime = false, $useTimezone = false, $useUtc = false) { $dateString = $this->getDateString($dateTime, $noTime, $useTimezone, $useUtc); $params = array(); if ($useTimezone) { $timeZone = $dateTime->getTimezone()->getName(); $params['TZID'] = $timeZone; } if ($noTime) { $params['VALUE'] = 'DATE'; } parent::__construct($name, $dateString, $params); }
/** * @param string $name * @param string $email */ public function __construct($name, $email = '') { $name = $name ? array('CN' => $name) : array(); $email = !$email ?: sprintf('MAILTO:%s', $email); return parent::__construct($this->getName(), $email, $name); }
/** * @param string $name * @param \DateTime $dateTime * @param bool $noTime * @param bool $useTimezone * @param bool $useUtc */ public function __construct($name, \DateTime $dateTime = null, $noTime = false, $useTimezone = false, $useUtc = false) { $dateString = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc); $params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone); parent::__construct($name, $dateString, $params); }
/** * Get all unfolded lines. * * @return array */ public function toLines() { if (!$this->value instanceof ValueInterface) { throw new \Exception('The value must implement the ValueInterface. Call RecurrenceId::applyTimeSettings() before adding RecurrenceId.'); } else { return parent::toLines(); } }
/** * @param string $value * @param array $params */ public function __construct($value, $params = array()) { parent::__construct(self::PROPERTY_NAME, $value, $params); }