/** * @dataProvider dataProviderTestParse */ public function testParse($string, $getWord, array $getStyles, $hasWord, $hasStyles, $isStyle) { $word = new Word($string); $this->assertSame($string, $word->getRawString()); $this->assertSame($getWord, $word->getWord()); $this->assertSame($getStyles, $word->getStyles()); $this->assertSame($hasWord, $word->hasWord()); $this->assertSame($hasStyles, $word->hasStyles()); $this->assertSame($isStyle, $word->isStyle()); }
/** * Constructor * * @param string $string String to parse */ public function __construct($string) { $this->rawString = $string; $parts = explode(self::CHAR_WORD, $string); foreach ($parts as $item) { $word = new Word($item); if ($word->isStyle()) { $this->styles = array_merge($this->styles, $word->getStyles()); } elseif ($word->hasWord()) { $this->words[] = $word; } } }