From cc9c3a3b30043537630359ca5e069d05a26e7821 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 8 Mar 2017 08:46:24 +0200 Subject: [PATCH] Remove mb_strimwidth --- app/Libraries/Utils.php | 5 +++++ app/Models/Expense.php | 2 +- app/Models/Task.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 676a7cfa8881..276a961be1c4 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -1228,4 +1228,9 @@ class Utils return round($amount + $tax1 + $tax2, 2); } + + public static function truncateString($string, $length) + { + return strlen($string) > $length ? rtrim(substr($string, 0, $length)) . '...' : $in; + } } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 2ebd51d18975..109c461b5d8a 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -137,7 +137,7 @@ class Expense extends EntityModel if ($this->transaction_id) { return $this->transaction_id; } elseif ($this->public_notes) { - return mb_strimwidth($this->public_notes, 0, 16, '...'); + return Utils::truncateString($this->public_notes, 16); } else { return '#' . $this->public_id; } diff --git a/app/Models/Task.php b/app/Models/Task.php index 52d2c4346ec2..782f1668dc04 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -196,7 +196,7 @@ class Task extends EntityModel public function getDisplayName() { if ($this->description) { - return mb_strimwidth($this->description, 0, 16, '...'); + return Utils::truncateString($this->description, 16); } return '#' . $this->public_id;