parseLine($line->getData()); } /** * Parses an 'RRULE' line and sets the member variables of this object. * Expects a string that looks like this: 'FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,TU,WE' * @param string $line the line to be parsed */ protected function parseLine($line) { $this->rrule = $line; //split up the properties $recurProperties = explode(';', $line); $recur = array(); //loop through the properties in the line and set their associated //member variables foreach ($recurProperties as $property) { $nameAndValue = explode('=', $property); //need the lower-case name for setting the member variable $propertyName = strtolower($nameAndValue[0]); $propertyValue = $nameAndValue[1]; //split up the list of values into an array (if it's a list) if (in_array($propertyName, $this->listProperties)) { $propertyValue = explode(',', $propertyValue); } $this->$propertyName = $propertyValue; } } /** * Set the $until member * @param mixed timestamp (int) / Valid DateTime format (string) */ public function setUntil($ts) { if ( is_int($ts) ) $dt = new DateTime('@'.$ts); else $dt = new DateTime($ts); $this->until = $dt->format('Ymd\THisO'); } /** * Retrieves the desired member variable and returns it (if it's set) * @param string $member name of the member variable * @return mixed the variable value (if set), false otherwise */ protected function getMember($member) { if (isset($this->$member)) { return $this->$member; } return false; } /** * Returns the frequency - corresponds to FREQ in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getFreq() { return $this->getMember('freq'); } /** * Returns when the event will go until - corresponds to UNTIL in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getUntil() { return $this->getMember('until'); } /** * Returns the count of the times the event will occur (should only appear if 'until' * does not appear) - corresponds to COUNT in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getCount() { return $this->getMember('count'); } /** * Returns the interval - corresponds to INTERVAL in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getInterval() { return $this->getMember('interval'); } /** * Returns the bysecond part of the event - corresponds to BYSECOND in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getBySecond() { return $this->getMember('bysecond'); } /** * Returns the byminute information for the event - corresponds to BYMINUTE in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByMinute() { return $this->getMember('byminute'); } /** * Corresponds to BYHOUR in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByHour() { return $this->getMember('byhour'); } /** *Corresponds to BYDAY in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByDay() { return $this->getMember('byday'); } /** * Corresponds to BYMONTHDAY in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByMonthDay() { return $this->getMember('bymonthday'); } /** * Corresponds to BYYEARDAY in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByYearDay() { return $this->getMember('byyearday'); } /** * Corresponds to BYYEARNO in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByYearNo() { return $this->getMember('byyearno'); } /** * Corresponds to BYMONTH in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getByMonth() { return $this->getMember('bymonth'); } /** * Corresponds to BYSETPOS in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getBySetPos() { return $this->getMember('bysetpos'); } /** * Corresponds to WKST in RFC 2445. * @return mixed string if the member has been set, false otherwise */ public function getWkst() { return $this->getMember('wkst'); } }