RegexParser::parseParenthesis()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.9
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 12
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