Passed
Push — master ( d8d9f2...800fb3 )
by Tom
02:30
created

Prefix   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A verify() 0 9 2
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Value;
6
7
use UnexpectedValueException;
8
9
/**
10
 * Class Prefix
11
 *
12
 * @package Ktomk\Pipelines\Value
13
 */
14
abstract class Prefix
15
{
16
    /**
17
     * @param string $prefix
18
     *
19
     * @return string
20
     */
21 1
    public static function verify($prefix)
22
    {
23 1
        if (preg_match('~^[a-z]{3,}$~', $prefix)) {
24 1
            return $prefix;
25
        }
26
27 1
        throw new UnexpectedValueException(sprintf(
28 1
            'invalid prefix: "%s"; a prefix is only lower-case letters with a minimum length of three characters',
29
            $prefix
30
        ));
31
    }
32
}
33