/**
  * Factory method that returns a FieldType object based on the first argument's contents.
  *
  * @param string    raw field representation
  *
  * @throws UnexpectedValueException when a value is given that doesn't follow the field type patterns.
  * @return static
  */
 public static function fromNative()
 {
     $value = func_get_arg(0);
     switch (true) {
         case preg_match(self::REGEX_TYPE_VARCHAR, $value, $matchesVarchar):
             $response = Varchar::fromNative($matchesVarchar[1]);
             break;
         case preg_match(self::REGEX_TYPE_CHAR, $value, $matchesVarchar):
             $response = Char::fromNative($matchesVarchar[1]);
             break;
         case preg_match(self::REGEX_TYPE_TIMESTAMP, $value, $matchesVarchar):
             $response = new Timestamp();
             break;
         case preg_match(self::REGEX_TYPE_DATETIME, $value, $matchesVarchar):
             $response = new Datetime();
             break;
         case preg_match(self::REGEX_TYPE_DATE, $value, $matchesVarchar):
             $response = new Date();
             break;
         case preg_match(self::REGEX_TYPE_TEXT, $value, $matchesVarchar):
             $response = new Text();
             break;
         case preg_match(self::REGEX_TYPE_INT_UNSIGNED, $value, $matchesVarchar):
             $response = IntUnsigned::fromNative($matchesVarchar[1]);
             break;
         case preg_match(self::REGEX_TYPE_INT_SIGNED, $value, $matchesVarchar):
             $response = IntSigned::fromNative($matchesVarchar[1]);
             break;
         case preg_match(self::REGEX_TYPE_DECIMAL, $value, $matchesVarchar):
             $response = Decimal::fromNative((int) $matchesVarchar[1], (int) $matchesVarchar[2]);
             break;
         case preg_match(self::REGEX_TYPE_TINYINT_SIGNED, $value, $matchesVarchar):
             $response = TinyIntSigned::fromNative($matchesVarchar[1]);
             break;
         case preg_match(self::REGEX_TYPE_ENUM, $value, $matchesVarchar):
             $response = Enum::fromNative($matchesVarchar[1]);
             break;
             // @todo Add more cases. http://dev.mysql.com/doc/refman/5.7/en/data-types.html
         // @todo Add more cases. http://dev.mysql.com/doc/refman/5.7/en/data-types.html
         default:
             $allowedPatterns = array_values(static::getConstants());
             throw new UnexpectedValueException($value, $allowedPatterns);
             break;
     }
     return $response;
 }
 /**
  * Returns the string representation of the char with the char length.
  */
 public function testReturnTheStringRepresentationOfTheCharWithTheCharLength()
 {
     $instance = new FieldType\Char(4);
     $result = $instance->toNative();
     static::assertEquals('char(4)', $result);
 }