Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-foundation/AcceptHeaderItem.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
16 * | 16 * |
17 * @author Jean-François Simon <contact@jfsimon.fr> | 17 * @author Jean-François Simon <contact@jfsimon.fr> |
18 */ | 18 */ |
19 class AcceptHeaderItem | 19 class AcceptHeaderItem |
20 { | 20 { |
21 /** | |
22 * @var string | |
23 */ | |
24 private $value; | 21 private $value; |
25 | |
26 /** | |
27 * @var float | |
28 */ | |
29 private $quality = 1.0; | 22 private $quality = 1.0; |
30 | |
31 /** | |
32 * @var int | |
33 */ | |
34 private $index = 0; | 23 private $index = 0; |
35 | |
36 /** | |
37 * @var array | |
38 */ | |
39 private $attributes = array(); | 24 private $attributes = array(); |
40 | 25 |
41 /** | 26 /** |
42 * Constructor. | |
43 * | |
44 * @param string $value | 27 * @param string $value |
45 * @param array $attributes | 28 * @param array $attributes |
46 */ | 29 */ |
47 public function __construct($value, array $attributes = array()) | 30 public function __construct($value, array $attributes = array()) |
48 { | 31 { |
65 $value = array_shift($bits); | 48 $value = array_shift($bits); |
66 $attributes = array(); | 49 $attributes = array(); |
67 | 50 |
68 $lastNullAttribute = null; | 51 $lastNullAttribute = null; |
69 foreach ($bits as $bit) { | 52 foreach ($bits as $bit) { |
70 if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'')) { | 53 if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ('"' === $start || '\'' === $start)) { |
71 $attributes[$lastNullAttribute] = substr($bit, 1, -1); | 54 $attributes[$lastNullAttribute] = substr($bit, 1, -1); |
72 } elseif ('=' === $end) { | 55 } elseif ('=' === $end) { |
73 $lastNullAttribute = $bit = substr($bit, 0, -1); | 56 $lastNullAttribute = $bit = substr($bit, 0, -1); |
74 $attributes[$bit] = null; | 57 $attributes[$bit] = null; |
75 } else { | 58 } else { |
76 $parts = explode('=', $bit); | 59 $parts = explode('=', $bit); |
77 $attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : ''; | 60 $attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : ''; |
78 } | 61 } |
79 } | 62 } |
80 | 63 |
81 return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value, $attributes); | 64 return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ('"' === $start || '\'' === $start) ? substr($value, 1, -1) : $value, $attributes); |
82 } | 65 } |
83 | 66 |
84 /** | 67 /** |
85 * Returns header value's string representation. | 68 * Returns header value's string representation. |
86 * | 69 * |