From 9c91e9820e20c93600ec7dd969a6f8242ffd90c4 Mon Sep 17 00:00:00 2001 From: Reece Alexander Date: Sun, 17 Dec 2017 17:21:42 +1000 Subject: [PATCH] Returns chainability in setValue from parent --- src/ORM/FieldType/DBCurrency.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ORM/FieldType/DBCurrency.php b/src/ORM/FieldType/DBCurrency.php index 25217a5ce..9c9a38db5 100644 --- a/src/ORM/FieldType/DBCurrency.php +++ b/src/ORM/FieldType/DBCurrency.php @@ -17,7 +17,6 @@ namespace SilverStripe\ORM\FieldType; */ class DBCurrency extends DBDecimal { - /** * @config * @var string @@ -38,9 +37,9 @@ class DBCurrency extends DBDecimal $val = $this->config()->currency_symbol . number_format(abs($this->value), 2); if ($this->value < 0) { return "($val)"; - } else { - return $val; } + + return $val; } /** @@ -51,9 +50,9 @@ class DBCurrency extends DBDecimal $val = $this->config()->currency_symbol . number_format(abs($this->value), 0); if ($this->value < 0) { return "($val)"; - } else { - return $val; } + return $val; + } public function setValue($value, $record = null, $markChanged = true) @@ -62,9 +61,11 @@ class DBCurrency extends DBDecimal if (is_numeric($value)) { $this->value = $value; } elseif (preg_match('/-?\$?[0-9,]+(.[0-9]+)?([Ee][0-9]+)?/', $value, $matches)) { - $this->value = str_replace(array('$',',',$this->config()->currency_symbol), '', $matches[0]); - } else { - $this->value = 0; + $this->value = str_replace(['$', ',', $this->config()->currency_symbol], '', $matches[0]); } + + $this->value = 0; + + return $this; } }