| 1 | <?php |
||
| 8 | class Scheme |
||
| 9 | { |
||
| 10 | private static $valid_pattern = '/^[a-z][\w\+\-\.]*$/i'; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Scheme constructor. Accepts a string representing a URI scheme. Construction will throw an exception if the |
||
| 14 | * scheme is either not a string or does not conform to the RFC3986 URI scheme specification. |
||
| 15 | * |
||
| 16 | * scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) |
||
| 17 | * |
||
| 18 | * @see https://tools.ietf.org/html/rfc3986#appendix-A |
||
| 19 | * |
||
| 20 | * @throws \InvalidArgumentException |
||
| 21 | * |
||
| 22 | * @param string $scheme A string representing a URI scheme |
||
| 23 | */ |
||
| 24 | 10 | public function __construct($scheme) |
|
| 32 | |||
| 33 | /** |
||
| 34 | * Determines whether a given scheme adheres to the RFC3986 specification: |
||
| 35 | * |
||
| 36 | * scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) |
||
| 37 | * |
||
| 38 | * @see https://tools.ietf.org/html/rfc3986#appendix-A |
||
| 39 | * @see Scheme::$valid_pattern |
||
| 40 | * |
||
| 41 | * @param string $scheme The scheme to check for validity |
||
| 42 | * @return bool Returns true if the provided scheme matches the RFC3986 specification |
||
| 43 | * Returns false otherwise |
||
| 44 | */ |
||
| 45 | 10 | public static function isValid($scheme) |
|
| 49 | } |
||
| 50 |