Solar_Sql_Adapter::_getTypeSizeScope PHP Method

_getTypeSizeScope() protected method

Given a column specification, parse into datatype, size, and decimal scope.
protected _getTypeSizeScope ( string $spec ) : array
$spec string The column specification; for example, "VARCHAR(255)" or "NUMERIC(10,2)".
return array A sequential array of the column type, size, and scope.
    protected function _getTypeSizeScope($spec)
    {
        $spec = strtolower($spec);
        $type = null;
        $size = null;
        $scope = null;
        // find the parens, if any
        $pos = strpos($spec, '(');
        if ($pos === false) {
            // no parens, so no size or scope
            $type = $spec;
        } else {
            // find the type first.
            $type = substr($spec, 0, $pos);
            // there were parens, so there's at least a size.
            // remove parens to get the size.
            $size = trim(substr($spec, $pos), '()');
            // a comma in the size indicates a scope.
            $pos = strpos($size, ',');
            if ($pos !== false) {
                $scope = substr($size, $pos + 1);
                $size = substr($size, 0, $pos);
            }
        }
        foreach ($this->_native_solar as $native => $solar) {
            // $type is already lowered
            if ($type == strtolower($native)) {
                $type = strtolower($solar);
                break;
            }
        }
        return array($type, $size, $scope);
    }