Passed
Push — master ( ca068f...f2d295 )
by Alexey
03:12 queued 16s
created

StringUtil::cp866toUtf8()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 12
nc 5
nop 1
dl 0
loc 18
rs 9.5555
c 0
b 0
f 0
1
<?php
2
3
namespace PhpZip\Util;
4
5
/**
6
 * String Util.
7
 *
8
 * @internal
9
 */
10
final class StringUtil
11
{
12
    /**
13
     * @param string $haystack
14
     * @param string $needle
15
     *
16
     * @return bool
17
     */
18
    public static function startsWith($haystack, $needle)
19
    {
20
        return $needle === '' || strrpos($haystack, $needle, -\strlen($haystack)) !== false;
21
    }
22
23
    /**
24
     * @param string $haystack
25
     * @param string $needle
26
     *
27
     * @return bool
28
     */
29
    public static function endsWith($haystack, $needle)
30
    {
31
        return $needle === '' || (($temp = \strlen($haystack) - \strlen($needle)) >= 0
32
                && strpos($haystack, $needle, $temp) !== false);
33
    }
34
}
35