Completed
Push — master ( 270997...67aaa2 )
by Mohamed
10s
created

Strings   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
dl 0
loc 23
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A split() 0 3 1
1
<?php
2
3
namespace __\Traits;
4
5
trait Strings
6
{
7
    /**
8
     * Split a string by string.
9
     *
10
     * Based on explode, see http://php.net/manual/en/function.explode.php.
11
     *
12
     * __::split('a-b-c', '-', 2);
13
     *      >> ['a', 'b-c']
14
     *
15
     * @param string $input     The string to split.
16
     * @param string $delimiter The boundary string.
17
     * @param int    $limit     (optional) If limit is set and positive, the returned array
18
     *                          will contain a maximum of limit elements with the last element containing the
19
     *                          rest of string.
20
     *                          If the limit parameter is negative, all components except the last -limit are returned.
21
     *                          If the limit parameter is zero, then this is treated as 1.
22
     *
23
     * @return string
24
     */
25 17
    public static function split($input, $delimiter, $limit = PHP_INT_MAX)
26
    {
27 17
        return explode($delimiter, $input, $limit);
0 ignored issues
show
Bug Best Practice introduced by
The expression return explode($delimiter, $input, $limit) returns the type array which is incompatible with the documented return type string.
Loading history...
28
    }
29
}