| Total Complexity | 2 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class TwitterHandleRule implements Rule |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Validation for Twitter handlers. |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | const PATTERN = '^[A-Za-z0-9_]{1,15}$'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * |
||
| 19 | * Twitters Terms of Service only allows ". A username can only contain |
||
| 20 | * alphanumeric characters (letters A-Z, numbers 0-9) with the exception |
||
| 21 | * of underscores... A username cannot be longer than 15 characters." |
||
| 22 | * This regex will allow only alphanumeric characters and the underscore. |
||
| 23 | * Keep this handy if we need to validate other usernames. |
||
| 24 | * |
||
| 25 | * @param string $attribute |
||
| 26 | * @param mixed $value |
||
| 27 | * @return boolean |
||
| 28 | */ |
||
| 29 | public function passes($attribute, $value) |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Get the validation error message. |
||
| 36 | * |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | public function message() |
||
| 44 |