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

Strings   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A startsWith() 0 9 4
A contains() 0 9 4
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