public loadFromString ( string $rrule ) : |
||
$rrule | string | RRULE string |
return |
public function loadFromString($rrule)
{
$rrule = strtoupper($rrule);
$rrule = trim($rrule, ';');
$pieces = explode(';', $rrule);
$parts = array();
if (!count($pieces)) {
throw new InvalidRRule('RRULE is empty');
}
// Split each piece of the RRULE in to KEY=>VAL
foreach ($pieces as $piece) {
if (false === strpos($piece, '=')) {
continue;
}
list($key, $val) = explode('=', $piece);
$parts[$key] = $val;
}
return $this->loadFromArray($parts);
}
public function testSetStartDateAffectsStringOutput() { $this->rule->loadFromString('FREQ=MONTHLY;COUNT=2'); $this->assertEquals('FREQ=MONTHLY;COUNT=2', $this->rule->getString()); $this->rule->setStartDate(new \DateTime('2015-12-10')); $this->assertEquals('FREQ=MONTHLY;COUNT=2', $this->rule->getString()); $this->rule->setStartDate(new \DateTime('2015-12-10'), true); $this->assertEquals('FREQ=MONTHLY;COUNT=2;DTSTART=20151210T000000', $this->rule->getString()); $this->rule->setStartDate(new \DateTime('2015-12-10'), false); $this->assertEquals('FREQ=MONTHLY;COUNT=2', $this->rule->getString()); }