/** * @todo Implement testConstructFromString(). */ public function testConstructFromString() { $this->assertEquals($this->object, phpMorphy_UserDict_GrammarIdentifier::constructFromString("PART_OF_SPEECH \t\t\t a , \t\t b\t\t , \t c ")); $obj2 = phpMorphy_UserDict_GrammarIdentifier::constructFromString("TEST \t\t\t"); $this->assertEquals('TEST', $obj2->getPartOfSpeech()); $this->assertEquals(array(), $obj2->getGrammems()); $obj3 = phpMorphy_UserDict_GrammarIdentifier::constructFromString("* \t\t\t"); $this->assertFalse($obj3->hasPartOfSpeech()); $this->assertEquals(array(), $obj3->getGrammems()); }
/** * @param string $string * @return phpMorphy_UserDict_Pattern */ static function constructFromString($string) { $string = trim($string); $sp_pos = strpos($string, ' '); $pattern = null; $word = $string; if (false !== $sp_pos) { $pattern_string = trim(substr($string, $sp_pos + 1)); if (strlen($pattern_string)) { $pattern = phpMorphy_UserDict_GrammarIdentifier::constructFromString($pattern_string); $word = substr($string, 0, $sp_pos); } } if (null === $pattern) { $pattern = phpMorphy_UserDict_GrammarIdentifier::construct(null, array()); } $clazz = __CLASS__; return new $clazz($word, $pattern); }