Ejemplo n.º 1
0
 /**
  * Parses a line, and if it hits a component, it will also attempt to parse
  * the entire component.
  *
  * @param string $line Unfolded line
  *
  * @return Node
  */
 protected function parseLine($line)
 {
     // Start of a new component
     if (strtoupper(substr($line, 0, 6)) === 'BEGIN:') {
         $component = $this->root->createComponent(substr($line, 6), [], false);
         while (true) {
             // Reading until we hit END:
             $line = $this->readLine();
             if (strtoupper(substr($line, 0, 4)) === 'END:') {
                 break;
             }
             $result = $this->parseLine($line);
             if ($result) {
                 $component->add($result);
             }
         }
         $name = strtoupper(substr($line, 4));
         if ($name !== $component->name) {
             throw new ParseException('Invalid MimeDir file. expected: "END:' . $component->name . '" got: "END:' . $name . '"');
         }
         return $component;
     } else {
         // Property reader
         $property = $this->readProperty($line);
         if (!$property) {
             // Ignored line
             return false;
         }
         return $property;
     }
 }