Completed
Pull Request — master (#3)
by
unknown
02:25
created

StringFn   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 44
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mysql_concat_ws() 0 7 1
A mysql_concat() 0 8 2
A mysql_format() 0 7 1
1
<?php
2
3
namespace Vectorface\MySQLite\MySQL;
4
5
/**
6
 * Provides String Manipulation MySQL compatibility functions for SQLite.
7
 *
8
 * http://dev.mysql.com/doc/refman/5.7/en/string-functions.html
9
 */
10
trait StringFn
11
{
12
13
     /**
14
     * Concat - Return a concatinated string of all function arguments provided
15
     * @return string $str concatinated string
16
     */
17 1
    public static function mysql_concat()
18
    {
19 1
        $str = '';
20 1
        foreach (func_get_args() as $arg) {
21 1
            $str .= $arg;
22
        }
23 1
        return $str;
24
    }
25
26
    /**
27
     * Concat_ws - Return a concatinated string of all function arguments provided
28
     * it will use the first argument as the seperator
29
     * @return string $str concactinated string with seperator
30
     */
31 1
    public static function mysql_concat_ws()
32
    {
33 1
        $args = func_get_args();
34 1
        $seperator = array_shift($args);
35 1
        $str = implode($seperator, $args);
36 1
        return $str;
37
    }
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 1
    public static function mysql_format()
47
    {
48 1
        $args = func_get_args();
49 1
        $number = $args[0];
50 1
        $decimals = $args[1];
51 1
        return number_format($number, $decimals);
52
    }
53
}
54