Skip to content

Commit

Permalink
重构代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Dec 9, 2022
1 parent 02a27e9 commit a1a176a
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions src/Struct/ColumnMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,34 @@ public function __construct(string $name, $type, int $length)
$this->setLength($length);
}

/**
* @return mixed
*/
public function __call(string $name, array $arguments)
public function getTypeName(?int $type = null): string
{
if ('getTypeName' === $name)
if (null === $type)
{
if ($arguments)
{
return self::TYPE_MAP[$arguments[0] ?? null] ?? null;
}
else
{
return $this->typeName;
}
return $this->typeName;
}
else
{
return self::TYPE_MAP[$type] ?? null;
}
}

public function getTypeValue(?string $typeName = null): int
{
if (null === $typeName)
{
return $this->type;
}
elseif ('getTypeValue' === $name)
else
{
if ($arguments)
$value = array_search($typeName, self::TYPE_MAP);
if (false === $value)
{
$value = array_search($arguments[0] ?? null, self::TYPE_MAP);
if (false === $value)
{
return self::TYPE_UNKNOWN;
}
else
{
return $value;
}
return self::TYPE_UNKNOWN;
}
else
{
return $this->type;
return $value;
}
}
}
Expand Down

0 comments on commit a1a176a

Please sign in to comment.