Passed
Push — master ( edaa23...d2a3cb )
by Radu
01:23
created

Strings::contains()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 4
nc 4
nop 3
1
<?php
2
namespace WebServCo\Framework\Utils;
3
4
final class Strings
5
{
6
    public static function startsWith($haystack, $needle, $ignoreCase = true)
7
    {
8
        if (false !== $ignoreCase) {
9
            $function = function_exists('mb_stripos') ? 'mb_stripos' : 'stripos';
10
        } else {
11
            $function = function_exists('mb_strpos') ? 'mb_strpos' : 'strpos';
12
        }
13
14
        return 0 === $function($haystack, $needle);
15
    }
16
17
    public static function contains($haystack, $needle, $ignoreCase = true)
18
    {
19
        if (false !== $ignoreCase) {
20
            $function = function_exists('mb_stripos') ? 'mb_stripos' : 'stripos';
21
        } else {
22
            $function = function_exists('mb_strpos') ? 'mb_strpos' : 'strpos';
23
        }
24
25
        return false !== $function($haystack, $needle);
26
    }
27
}
28