Return a decimal type-formatted string

@param array $values Contains a tokenised list of info about this data type
@return string
333617
public function decimal($values)
    {
        // Avoid empty strings being put in the db
        if ($values['precision'] == '') {
            $precision = 1;
        } else {
            $precision = $values['precision'];
        }

        $defaultValue = '0';
        if (isset($values['default']) && is_numeric($values['default'])) {
            $defaultValue = $values['default'];
        }

        return "decimal($precision) not null default $defaultValue";
    }
875341
public static function formatToDecimal($value, $decimals = 2)
    {
        if (trim($value) != null) {
            return number_format($value, $decimals, '.', '');
        }
        return null;
    }
979379
public static function format($value, int $decimals = 2): ?string {
        if (!\is_numeric($value)) {
            return null;
        }
        return \number_format($value, $decimals);
    }
14541
public static function decimalFormat($value)
    {
        if (is_int($value)) {
            return $value;
        }else if (is_float($value)) {
            if (strcspn(strrev($value), '.') >= 3) {
                $value = floor($value * 100) / 100;
            }
        }
        return (string)number_format($value, 2, '.', '');
    }
1056501
private function normalizeBetweenValues(array $values): ?array
    {
        if (2 !== \count($values)) {
            $this->getLogger()->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('Invalid format for "[%s]", expected "<min>..<max>"', self::PARAMETER_BETWEEN)),
            ]);

            return null;
        }

        if (!is_numeric($values[0]) || !is_numeric($values[1])) {
            $this->getLogger()->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('Invalid values for "[%s]" range, expected numbers', self::PARAMETER_BETWEEN)),
            ]);

            return null;
        }

        return [$values[0] + 0, $values[1] + 0]; // coerce to the right types.
    }
39807
protected function formatValues($values) : string {
    if (is_array($values)) {
      return ':' . implode(', :', $values);
    }

    if (is_string($values)) {
      $values = explode(',', $values);

      $values = array_map(function($value) {
        return ':' . trim($value);
      }, $values);

      return implode(', ', $values);
    }
  }
316810
protected function getPreferredValue(array $values)
    {
        foreach ($values as $v) {
            if (!is_null($v) && !empty($v)) {
                return $v;
            }
        }

        return '';
    }
367892
public function varchar($values)
    {
        //For reference, this is what typically gets passed to this function:
        //$parts=Array('datatype'=>'varchar', 'precision'=>$this->size, 'character set'=>'utf8', 'collate'=>
        //'utf8_general_ci');
        //DB::requireField($this->tableName, $this->name, "varchar($this->size) character set utf8 collate
        // utf8_general_ci");
        $default = $this->defaultClause($values);
        $charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
        $collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
        return "varchar({$values['precision']}) character set {$charset} collate {$collation}{$default}";
    }
266638
protected static function getValueAsINI($value)
    {
        $string = '';

        switch (gettype($value)) {
            case 'integer':
            case 'double':
                $string = $value;
                break;

            case 'boolean':
                $string = $value ? 'true' : 'false';
                break;

            case 'string':
                // Sanitize any CRLF characters..
                $string = '"' . str_replace(["\r\n", "\n"], '\\n', $value) . '"';
                break;
        }

        return $string;
    }
478240
public function decimal($values, string $currency = null, int $decimal_points = 2): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->decimal($value, $decimal_points);
    }
1359718
public function convert($value)
    {
        if (!is_scalar($value)) {
            return false;
        }

        if (is_string($value)) {
            return $value;
        }

        if (is_float($value)) {
            return sprintf('float_%.4f', $value);
        }

        $prefix = '';

        if (!is_bool($value)) {
            $prefix = gettype($value) . '_';
        }

        
        return $prefix . var_export($value, true);
    }
279641
public function getString($value)
    {
        $number = floatval($value);
        $number = round(($number + 0.000001) * 20) / 20;

        return sprintf('CHF %s',
            number_format($number, 2, '.', '\'')
        );
    }
4252
public function groupQueryValues(array $values)
    {
        $joined = Resources::EMPTY_STRING;

        foreach ($values as $value) {
            if (!is_null($value) && !empty($value)) {
                $joined .= $value.Resources::SEPARATOR;
            }
        }

        return trim($joined, Resources::SEPARATOR);
    }
819302
public static function format($value)
    {
        $value = (string) $value;

        if (Utils::isAddress($value)) {
            $value = mb_strtolower($value);

            if (Utils::isZeroPrefixed($value)) {
                return $value;
            }
            return '0x' . $value;
        }
        $value = IntegerFormatter::format($value, 40);

        return '0x' . $value;
    }
1062240
public function evaluate( $values )
    {
        $returnValue = false;

        if (is_string( $values ) || is_numeric( $values )) {
            $returnValue = (preg_match( $this->getOption('format'), $values ) === 1);
        }

        return $returnValue;
    }
857522
public function permalinkForValues(array $values) : string
    {
        for ($i = 0; $i < count($values); $i++) {
            $values[$i] = Permalink::createSlug($values[$i]);
        }
        $value = implode('-', $values);

        return $this->getNumeration($value);
    }
944093
public function getSanitizedValues(&$values = [])
    {
        array_walk($this->fields, function ($field, $index) use (&$values) {
            if (is_array($field)) {
                return $this->sanitizeConditionalValues($values, $field, $index);
            }

            return $this->sanitizeValues($values[$field->getSlug()], $field);
        });

        return $values;
    }