Str::startsWith()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 4
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AcquiroPay;
6
7
class Str
8
{
9
    /**
10
     * Determine if a given string starts with a given substring.
11
     *
12
     * @param  string $haystack
13
     * @param  string|array $needles
14
     *
15
     * @return bool
16
     */
17
    public static function startsWith($haystack, $needles): bool
18
    {
19
        foreach ((array) $needles as $needle) {
20
            if ($needle !== '' && 0 === strpos($haystack, (string) $needle)) {
21
                return true;
22
            }
23
        }
24
25
        return false;
26
    }
27
}
28