GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b22946...56139c )
by Gilles
02:11
created

functions.php ➔ split_enclosed()   C

Complexity

Conditions 7
Paths 10

Size

Total Lines 28
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 18
nc 10
nop 4
dl 0
loc 28
rs 6.7272
c 0
b 0
f 0
1
<?php
2
3
namespace PHPFunctional\PatternMatching;
4
5
function split_enclosed($delimiter, $open, $close, $string)
6
{
7
    $chars = str_split($string);
8
9
    $result = [];
10
    $buffer = '';
11
    $level = 0;
12
    foreach($chars as $c) {
13
        if($c === $delimiter && $level === 0) {
14
            $result[] = $buffer;
15
            $buffer = '';
16
        } else {
17
            $buffer .= $c;
18
19
            if($c === $open) {
20
                ++$level;
21
            } else if($c === $close) {
22
                --$level;
23
            }
24
        }
25
    }
26
27
    if(strlen($buffer) > 0) {
28
        $result[] = $buffer;
29
    }
30
31
    return $result;
32
}
33