Passed
Push — master ( 2fe95c...80875d )
by Alec
03:34
created

Strip   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A escCodes() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Spinner\Core;
4
5
class Strip
6
{
7
    protected const REG_EXP = '#\\x1b[[][^A-Za-z]*[A-Za-z]#';
8
9 34
    public static function escCodes(string $in): string
10
    {
11 34
        $str = preg_replace(self::REG_EXP, '', $in);
12 34
        if (PREG_NO_ERROR !== $error = preg_last_error()) {
13
            // @codeCoverageIgnoreStart
14
            throw new \RuntimeException('Failed to apply regex. Code: ' . $error, $error);
15
            // @codeCoverageIgnoreEnd
16
        }
17 34
        return (string)$str;
18
    }
19
}
20