norm_join()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Strings normalization functions
4
 *
5
 * @category helper functions
6
 * @package  Normie
7
 * @author   David J Eddy <[email protected]>
8
 * @license  MIT
9
 * @link     https://github.com/davidjeddy/normie
10
 */
11
12
/**
13
 * Swapping $delimiter and $string positions
14
 *
15
 * @param  string $string
16
 * @param  string $delimiter
17
 * @param  int    $limit
18
 * @return array<int, string>|false
19
 */
20
function norm_explode(string $string, string $delimiter, $limit = PHP_INT_MAX)
21
{
22
    return explode($delimiter, $string, $limit);
23
}
24
25
/**
26
 * Swapping $glue and $pieces positions
27
 *
28
 * @param  array  $pieces
29
 * @param  string $glue
30
 * @return string
31
 */
32
function norm_implode(array $pieces, string $glue): string
33
{
34
    return implode($glue, $pieces);
35
}
36
37
/**
38
 * Swapping $glue and $pieces positions
39
 *
40
 * @param  string $glue
41
 * @param  array  $pieces
42
 * @return string
43
 */
44
function norm_join(array $pieces, string $glue): string
45
{
46
    return implode($glue, $pieces);
47
}
48
49
/**
50
 * @param  mixed   $subject
51
 * @param  mixed   $search
52
 * @param  mixed   $replace
53
 * @param  integer $count
54
 * @return mixed
55
 */
56
function norm_str_replace($subject, $search, $replace, $count = 1)
57
{
58
    return str_replace($search, $replace, $subject, $count);
59
}
60
61
/**
62
 * Added return value.
63
 *
64
 * @param  string $string
65
 * @param  array  $result
66
 * @return array
67
 */
68
function norm_parse_str(string $string, array &$result): array
69
{
70
    parse_str($string, $result);
71
72
    return $result;
73
}
74