Skip to content

Commit 0f501a3

Browse files
committed
fixed function collisions
1 parent 09ae057 commit 0f501a3

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/helpers.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ function clean_content_type($content_type){
77
return trim(preg_replace('@;.*@', '', $content_type));
88
}
99

10-
function starts_with($haystack, $needles){
11-
foreach( (array)$needles as $n){
12-
if($n !== '' && stripos($haystack, $n) === 0){
13-
return true;
10+
11+
if(!function_exists('starts_with')){
12+
13+
function starts_with($haystack, $needles){
14+
foreach( (array)$needles as $n){
15+
if($n !== '' && stripos($haystack, $n) === 0){
16+
return true;
17+
}
1418
}
19+
20+
return false;
1521
}
16-
17-
return false;
1822
}
1923

20-
function str_before($subject, $search){
21-
return $search === '' ? $subject : explode($search, $subject)[0];
24+
if(!function_exists('str_before')){
25+
26+
function str_before($subject, $search){
27+
return $search === '' ? $subject : explode($search, $subject)[0];
28+
}
2229
}
2330

24-
2531
function is_html($content_type){
2632
return clean_content_type($content_type) == 'text/html';
2733
}

0 commit comments

Comments
 (0)