Completed
Push — test ( d8d9f2...ee908a )
by Tom
14:20 queued 28s
created

Prefix::verify()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
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