File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
src/Vectorface/MySQLite/MySQL
tests/Vectorface/Tests/MySQLite Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -35,4 +35,19 @@ public static function mysql_concat_ws()
3535 $ str = implode ($ seperator , $ args );
3636 return $ str ;
3737 }
38+
39+
40+ /**
41+ * Format - Return a formated number string based on the arguements provided
42+ * Ignoring the functionality of a third argument, locale
43+ * https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_format
44+ * @return string $str formatted as per arg
45+ */
46+ public static function mysql_format ()
47+ {
48+ $ args = func_get_args ();
49+ $ number = $ args [0 ];
50+ $ decimals = $ args [1 ];
51+ return number_format ($ number , $ decimals );
52+ }
3853}
Original file line number Diff line number Diff line change @@ -156,4 +156,15 @@ public function testRand()
156156 array_slice ($ results , 10 , 10 )
157157 );
158158 }
159+
160+ public function testFormat ()
161+ {
162+ $ expected = '12,312,312 ' ;
163+ $ test = MySQLite::mysql_format ("12312312.232 " , 0 );
164+ $ this ->assertEquals ($ expected , $ test );
165+
166+ $ expected = '12.2 ' ;
167+ $ test = MySQLite::mysql_format ("12.232 " , 1 );
168+ $ this ->assertEquals ($ expected , $ test );
169+ }
159170}
You can’t perform that action at this time.
0 commit comments