Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
15 | abstract class Prefix |
||
16 | { |
||
17 | const DEFAULT_PREFIX = App::UTILITY_NAME; |
||
18 | |||
19 | /** |
||
20 | * @param string $prefix |
||
21 | * |
||
22 | * @return string |
||
23 | */ |
||
24 | 2 | public static function verify($prefix) |
|
25 | { |
||
26 | 2 | if (preg_match('~^[a-z]{3,}$~', $prefix)) { |
|
27 | 2 | return $prefix; |
|
28 | } |
||
29 | |||
30 | 1 | throw new UnexpectedValueException(sprintf( |
|
31 | 1 | 'invalid prefix: "%s"; a prefix is only lower-case letters with a minimum length of three characters', |
|
32 | $prefix |
||
33 | )); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * filter a prefix |
||
38 | * |
||
39 | * always return a verified prefix (string) |
||
40 | * |
||
41 | * @param null|string $prefix [optional] if null, defaults to the default prefix |
||
42 | * |
||
43 | * @return string verified prefix |
||
44 | */ |
||
45 | 1 | public static function filter($prefix = null) |
|
54 | } |
||
55 | } |
||
56 |