Skip to content

Commit a1a176a

Browse files
committed
重构代码
1 parent 02a27e9 commit a1a176a

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

src/Struct/ColumnMeta.php

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,39 +101,34 @@ public function __construct(string $name, $type, int $length)
101101
$this->setLength($length);
102102
}
103103

104-
/**
105-
* @return mixed
106-
*/
107-
public function __call(string $name, array $arguments)
104+
public function getTypeName(?int $type = null): string
108105
{
109-
if ('getTypeName' === $name)
106+
if (null === $type)
110107
{
111-
if ($arguments)
112-
{
113-
return self::TYPE_MAP[$arguments[0] ?? null] ?? null;
114-
}
115-
else
116-
{
117-
return $this->typeName;
118-
}
108+
return $this->typeName;
109+
}
110+
else
111+
{
112+
return self::TYPE_MAP[$type] ?? null;
113+
}
114+
}
115+
116+
public function getTypeValue(?string $typeName = null): int
117+
{
118+
if (null === $typeName)
119+
{
120+
return $this->type;
119121
}
120-
elseif ('getTypeValue' === $name)
122+
else
121123
{
122-
if ($arguments)
124+
$value = array_search($typeName, self::TYPE_MAP);
125+
if (false === $value)
123126
{
124-
$value = array_search($arguments[0] ?? null, self::TYPE_MAP);
125-
if (false === $value)
126-
{
127-
return self::TYPE_UNKNOWN;
128-
}
129-
else
130-
{
131-
return $value;
132-
}
127+
return self::TYPE_UNKNOWN;
133128
}
134129
else
135130
{
136-
return $this->type;
131+
return $value;
137132
}
138133
}
139134
}

0 commit comments

Comments
 (0)