Passed
Push — master ( e7e3c4...d0e289 )
by Rogier
01:26
created

Str   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 9
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A endsWith() 0 9 3
A contains() 0 9 4
1
<?php
2
3
namespace Rogierw\RwAcme\Support;
4
5
class Str
6
{
7
    public static function contains($haystack, $needles): bool
8
    {
9
        foreach ((array) $needles as $needle) {
10
            if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
11
                return true;
12
            }
13
        }
14
15
        return false;
16
    }
17
18
    public static function endsWith($haystack, $needles)
19
    {
20
        foreach ((array) $needles as $needle) {
21
            if (substr($haystack, -strlen($needle)) === (string) $needle) {
22
                return true;
23
            }
24
        }
25
26
        return false;
27
    }
28
}
29