Completed
Push — master ( 658ffe...da5f24 )
by Limon
02:18
created

Str   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A startsWith() 0 5 1
A endsWith() 0 9 2
A contains() 0 4 1
1
<?php
2
namespace Limonte;
3
4
class Str
5
{
6 18
    public static function startsWith($haystack, $needle)
7
    {
8 18
        $length = mb_strlen($needle);
9 18
        return (mb_substr($haystack, 0, $length) === $needle);
10
    }
11
12 18
    public static function endsWith($haystack, $needle)
13
    {
14 18
        $length = mb_strlen($needle);
15 18
        if ($length == 0) {
16 1
            return true;
17
        }
18
19 18
        return (mb_substr($haystack, -$length) === $needle);
20
    }
21
22 18
    public static function contains($haystack, $needle)
23
    {
24 18
        return strpos($haystack, $needle) !== false;
25
    }
26
}
27