RegexParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 20
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseParenthesis() 0 11 3
1
<?php
2
3
namespace Webfactor\Laravel\Generators\Helper;
4
5
class RegexParser
6
{
7
    /**
8
     * Parses a string and returns the string left from and inside the parenthesis: left(inside)
9
     *
10
     * @param string $string
11
     * @return array
12
     */
13
    public static function parseParenthesis(string $string): array
14
    {
15
        if (str_contains($string, '(') && str_contains($string, ')')) {
16
            preg_match('/(.*)(\((.*)\))/', $string, $match);
17
        }
18
19
        return [
20
            'left' => $match[1] ?? $string,
21
            'inside' => $match[3] ?? '',
22
        ];
23
    }
24
}
25