18 private $linesGenerator;
30 return new self($content);
39 $this->content = $content;
47 $this->linesGenerator = $this->getLinesGenerator();
48 $this->component = $this->handle();
56 private function getLinesGenerator(): ?Generator
58 $tmp = explode(
"\r\n", $this->content);
60 for ($i = 0, $length = count($tmp); $i < $length; $i++)
62 $line = rtrim($tmp[$i]);
64 while (isset($tmp[$i + 1]) && mb_strlen($tmp[$i + 1]) > 0 && ($tmp[$i + 1][0] ===
' ' || $tmp[$i + 1][0] ===
"\t" ))
66 $line .= rtrim(mb_substr($tmp[++$i],1));
78 private function handle(): ?ParserComponent
82 $componentsCollection =
new ComponentsCollection();
84 while ($str = $this->linesGenerator->current())
93 $componentsCollection->add($this->handle());
97 $componentName = mb_strtolower($line->getValue());
100 elseif ($line->isEnd())
103 ->createComponent($properties, $componentsCollection)
106 elseif (in_array($line->getName(), [
'attendee',
'attach']))
109 ->addParameters($line->getParams())
110 ->setValue($line->getValue());
115 ->addParameters($line->getParams())
116 ->setValue($line->getValue());
119 $this->linesGenerator->next();
130 return ($this->component instanceof
Calendar)