| 1 | <?php |
||
| 10 | class Validator |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The regular expression for a valid identifier. |
||
| 14 | */ |
||
| 15 | const IDENTIFIER_REGEX = '/^[0-9A-Za-z\-]+$/'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The regular expression for a valid semantic version number. |
||
| 19 | */ |
||
| 20 | const VERSION_REGEX = '/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Checks if a identifier is valid. |
||
| 24 | * |
||
| 25 | * @param string $identifier A identifier. |
||
| 26 | * |
||
| 27 | * @return boolean TRUE if the identifier is valid, FALSE If not. |
||
| 28 | */ |
||
| 29 | public static function isIdentifier($identifier) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Checks if a number is a valid version number. |
||
| 36 | * |
||
| 37 | * @param integer $number A number. |
||
| 38 | * |
||
| 39 | * @return boolean TRUE if the number is valid, FALSE If not. |
||
| 40 | */ |
||
| 41 | public static function isNumber($number) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Checks if the string representation of a version number is valid. |
||
| 48 | * |
||
| 49 | * @param string $version The string representation. |
||
| 50 | * |
||
| 51 | * @return boolean TRUE if the string representation is valid, FALSE if not. |
||
| 52 | */ |
||
| 53 | public static function isVersion($version) |
||
| 57 | } |
||
| 58 |