Ejemplo n.º 1
0
 static function create(phpMorphy_Storage $storage, $lazy)
 {
     if ($lazy) {
         return new phpMorphy_GramInfo_Proxy($storage);
     }
     $header = phpMorphy_GramInfo::readHeader($storage->read(0, self::HEADER_SIZE));
     if (!phpMorphy_GramInfo::validateHeader($header)) {
         throw new phpMorphy_Exception('Invalid graminfo format');
     }
     $storage_type = $storage->getTypeAsString();
     $file_path = dirname(__FILE__) . "/access/graminfo_{$storage_type}.php";
     $clazz = '\\phpMorphy\\phpMorphy_GramInfo_' . ucfirst($storage_type);
     require_once $file_path;
     return new $clazz($storage->getResource(), $header);
 }