Completed
Push — master ( c51846...2d4307 )
by ignace nyamagana
04:22 queued 02:03
created

functions.php ➔ is_bom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
* This file is part of the League.csv library
4
*
5
* @license http://opensource.org/licenses/MIT
6
* @link https://github.com/thephpleague/csv/
7
* @version 9.0.0
8
* @package League.csv
9
*
10
* For the full copyright and license information, please view the LICENSE
11
* file that was distributed with this source code.
12
*/
13
declare(strict_types=1);
14
15
namespace League\Csv;
16
17
use ReflectionClass;
18
19
/**
20
 * Returns the BOM sequence found at the start of the string
21
 *
22
 * If no valid BOM sequence is found an empty string is returned
23
 *
24
 * @internal used internally to detect the BOM sequence
25
 *
26
 * @param string $str
27
 *
28
 * @return string
29
 */
30
function bom_match(string $str): string
31
{
32 162
    static $list;
33
34 162
    $list = $list ?? (new ReflectionClass(BOM::class))->getConstants();
35
36 162
    foreach ($list as $sequence) {
37 162
        if (0 === strpos($str, $sequence)) {
38 94
            return $sequence;
39
        }
40
    }
41
42 136
    return '';
43
}
44