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

Str::endsWith()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 2
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