Esempio n. 1
0
 /**
  * @dataProvider dataProviderTestDefine
  */
 public function testDefine($string, $isDefine, $getDefineKey, $getDefineWord)
 {
     $line = new Line($string);
     $this->assertSame($isDefine, $line->isDefine());
     $this->assertSame($getDefineKey, $line->getDefineKey());
     if (is_null($getDefineWord)) {
         $this->assertNull($line->getDefineWord());
     } else {
         $word = $line->getDefineWord();
         $this->assertInstanceOf('\\Inml\\Text\\Word', $word);
         $this->assertSame($getDefineWord, $word->getWord());
     }
 }
Esempio n. 2
0
 /**
  * Constructor
  *
  * @param string $string String to parse
  */
 public function __construct($string)
 {
     $this->rawString = $string;
     $parts = explode(Line::SEPARATOR, $string);
     foreach ($parts as $item) {
         $line = new Line($item);
         if ($line->isStyle()) {
             $this->styles = array_merge($this->styles, $line->getStyles());
         } elseif ($line->isDefine()) {
             $this->defines[$line->getDefineKey()] = $line->getDefineWord();
         } elseif (!$line->isEmpty()) {
             $this->lines[] = $line;
         }
     }
 }