Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / zendframework / zend-diactoros / src / functions / marshal_protocol_version_from_sapi.php
1 <?php
2 /**
3  * @see       https://github.com/zendframework/zend-diactoros for the canonical source repository
4  * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5  * @license   https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6  */
7
8 namespace Zend\Diactoros;
9
10 use UnexpectedValueException;
11
12 use function preg_match;
13
14 /**
15  * Return HTTP protocol version (X.Y) as discovered within a `$_SERVER` array.
16  *
17  * @param array $server
18  * @return string
19  * @throws UnexpectedValueException if the $server['SERVER_PROTOCOL'] value is
20  *     malformed.
21  */
22 function marshalProtocolVersionFromSapi(array $server)
23 {
24     if (! isset($server['SERVER_PROTOCOL'])) {
25         return '1.1';
26     }
27
28     if (! preg_match('#^(HTTP/)?(?P<version>[1-9]\d*(?:\.\d)?)$#', $server['SERVER_PROTOCOL'], $matches)) {
29         throw new UnexpectedValueException(sprintf(
30             'Unrecognized protocol version (%s)',
31             $server['SERVER_PROTOCOL']
32         ));
33     }
34
35     return $matches['version'];
36 }