-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathStringFunctions.php
More file actions
61 lines (54 loc) · 1.61 KB
/
StringFunctions.php
File metadata and controls
61 lines (54 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Vectorface\MySQLite\MySQL;
/**
* Provides String Manipulation MySQL compatibility functions for SQLite.
*
* http://dev.mysql.com/doc/refman/5.7/en/string-functions.html
*/
trait StringFunctions
{
/**
* Concat - Return a concatenated string of all function arguments provided
* @return string $str concatenated string
*/
public static function mysql_concat()
{
$str = '';
foreach (func_get_args() as $arg) {
$str .= $arg;
}
return $str;
}
/**
* Concat_ws - Return a concatenated string of all function arguments provided
* it will use the first argument as the separator
* @return string $str concatenated string with separator
*/
public static function mysql_concat_ws()
{
$args = func_get_args();
$seperator = array_shift($args);
$str = implode($seperator, $args);
return $str;
}
/**
* Format - Return a formated number string based on the arguments provided
* Ignoring the functionality of a third argument, locale
* https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_format
* @return string $str formatted as per arg
*/
public static function mysql_format()
{
$args = func_get_args();
$number = isset($args[0]) ? $args[0] : 0.0;
$decimals = isset($args[1]) ? $args[1] : 0;
return number_format($number, $decimals);
}
/**
* Get the soundex value of a given string
*/
public static function mysql_soundex(string $str): string
{
return soundex($str);
}
}