PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / stripe / stripe-php / lib / Util / CaseInsensitiveArray.php
ameliabooking / vendor / stripe / stripe-php / lib / Util Last commit date
ApiVersion.php 6 months ago CaseInsensitiveArray.php 6 months ago DefaultLogger.php 6 months ago EventTypes.php 6 months ago LoggerInterface.php 6 months ago ObjectTypes.php 6 months ago RandomGenerator.php 6 months ago RequestOptions.php 6 months ago Set.php 6 months ago Util.php 6 months ago
CaseInsensitiveArray.php
97 lines
1 <?php
2
3 namespace AmeliaVendor\Stripe\Util;
4
5 /**
6 * CaseInsensitiveArray is an array-like class that ignores case for keys.
7 *
8 * It is used to store HTTP headers. Per RFC 2616, section 4.2:
9 * Each header field consists of a name followed by a colon (":") and the field value. Field names
10 * are case-insensitive.
11 *
12 * In the context of stripe-php, this is useful because the API will return headers with different
13 * case depending on whether HTTP/2 is used or not (with HTTP/2, headers are always in lowercase).
14 */
15 class CaseInsensitiveArray implements \ArrayAccess, \Countable, \IteratorAggregate
16 {
17 private $container = [];
18
19 public function __construct($initial_array = [])
20 {
21 $this->container = \array_change_key_case($initial_array, \CASE_LOWER);
22 }
23
24 /**
25 * @return int
26 */
27 #[\ReturnTypeWillChange]
28 public function count()
29 {
30 return \count($this->container);
31 }
32
33 /**
34 * @return \ArrayIterator
35 */
36 #[\ReturnTypeWillChange]
37 public function getIterator()
38 {
39 return new \ArrayIterator($this->container);
40 }
41
42 /**
43 * @return void
44 */
45 #[\ReturnTypeWillChange]
46 public function offsetSet($offset, $value)
47 {
48 $offset = self::maybeLowercase($offset);
49 if (null === $offset) {
50 $this->container[] = $value;
51 } else {
52 $this->container[$offset] = $value;
53 }
54 }
55
56 /**
57 * @return bool
58 */
59 #[\ReturnTypeWillChange]
60 public function offsetExists($offset)
61 {
62 $offset = self::maybeLowercase($offset);
63
64 return isset($this->container[$offset]);
65 }
66
67 /**
68 * @return void
69 */
70 #[\ReturnTypeWillChange]
71 public function offsetUnset($offset)
72 {
73 $offset = self::maybeLowercase($offset);
74 unset($this->container[$offset]);
75 }
76
77 /**
78 * @return mixed
79 */
80 #[\ReturnTypeWillChange]
81 public function offsetGet($offset)
82 {
83 $offset = self::maybeLowercase($offset);
84
85 return isset($this->container[$offset]) ? $this->container[$offset] : null;
86 }
87
88 private static function maybeLowercase($v)
89 {
90 if (\is_string($v)) {
91 return \strtolower($v);
92 }
93
94 return $v;
95 }
96 }
97