PluginProbe ʕ •ᴥ•ʔ
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 25.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v25.9
27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 19.1 19.10 19.11 19.12 19.13 19.14 19.2 19.3 19.4 19.5 19.5.1 19.6 19.6.1 19.7 19.7.1 19.7.2 19.8 19.9 20.0 20.1 20.10 20.11 20.12 20.13 20.2 20.2.1 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.8.1 21.9 21.9.1 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.8.1 24.9 25.0 25.1 25.2 25.3 25.3.1 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.1.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.1.1 27.2 27.3 27.4
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src / Query.php
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src Last commit date
Exception 2 years ago AppendStream.php 2 years ago BufferStream.php 2 years ago CachingStream.php 2 years ago DroppingStream.php 2 years ago FnStream.php 2 years ago Header.php 2 years ago HttpFactory.php 2 years ago InflateStream.php 2 years ago LazyOpenStream.php 2 years ago LimitStream.php 2 years ago Message.php 2 years ago MessageTrait.php 2 years ago MimeType.php 2 years ago MultipartStream.php 2 years ago NoSeekStream.php 2 years ago PumpStream.php 2 years ago Query.php 2 years ago Request.php 2 years ago Response.php 2 years ago Rfc7230.php 2 years ago ServerRequest.php 2 years ago Stream.php 2 years ago StreamDecoratorTrait.php 2 years ago StreamWrapper.php 2 years ago UploadedFile.php 2 years ago Uri.php 2 years ago UriComparator.php 2 years ago UriNormalizer.php 2 years ago UriResolver.php 2 years ago Utils.php 2 years ago
Query.php
105 lines
1 <?php
2
3 declare (strict_types=1);
4 namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
5
6 final class Query
7 {
8 /**
9 * Parse a query string into an associative array.
10 *
11 * If multiple values are found for the same key, the value of that key
12 * value pair will become an array. This function does not parse nested
13 * PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
14 * will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
15 *
16 * @param string $str Query string to parse
17 * @param int|bool $urlEncoding How the query string is encoded
18 */
19 public static function parse(string $str, $urlEncoding = \true) : array
20 {
21 $result = [];
22 if ($str === '') {
23 return $result;
24 }
25 if ($urlEncoding === \true) {
26 $decoder = function ($value) {
27 return \rawurldecode(\str_replace('+', ' ', (string) $value));
28 };
29 } elseif ($urlEncoding === \PHP_QUERY_RFC3986) {
30 $decoder = 'rawurldecode';
31 } elseif ($urlEncoding === \PHP_QUERY_RFC1738) {
32 $decoder = 'urldecode';
33 } else {
34 $decoder = function ($str) {
35 return $str;
36 };
37 }
38 foreach (\explode('&', $str) as $kvp) {
39 $parts = \explode('=', $kvp, 2);
40 $key = $decoder($parts[0]);
41 $value = isset($parts[1]) ? $decoder($parts[1]) : null;
42 if (!\array_key_exists($key, $result)) {
43 $result[$key] = $value;
44 } else {
45 if (!\is_array($result[$key])) {
46 $result[$key] = [$result[$key]];
47 }
48 $result[$key][] = $value;
49 }
50 }
51 return $result;
52 }
53 /**
54 * Build a query string from an array of key value pairs.
55 *
56 * This function can use the return value of `parse()` to build a query
57 * string. This function does not modify the provided keys when an array is
58 * encountered (like `http_build_query()` would).
59 *
60 * @param array $params Query string parameters.
61 * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
62 * to encode using RFC3986, or PHP_QUERY_RFC1738
63 * to encode using RFC1738.
64 */
65 public static function build(array $params, $encoding = \PHP_QUERY_RFC3986) : string
66 {
67 if (!$params) {
68 return '';
69 }
70 if ($encoding === \false) {
71 $encoder = function (string $str) : string {
72 return $str;
73 };
74 } elseif ($encoding === \PHP_QUERY_RFC3986) {
75 $encoder = 'rawurlencode';
76 } elseif ($encoding === \PHP_QUERY_RFC1738) {
77 $encoder = 'urlencode';
78 } else {
79 throw new \InvalidArgumentException('Invalid type');
80 }
81 $qs = '';
82 foreach ($params as $k => $v) {
83 $k = $encoder((string) $k);
84 if (!\is_array($v)) {
85 $qs .= $k;
86 $v = \is_bool($v) ? (int) $v : $v;
87 if ($v !== null) {
88 $qs .= '=' . $encoder((string) $v);
89 }
90 $qs .= '&';
91 } else {
92 foreach ($v as $vv) {
93 $qs .= $k;
94 $vv = \is_bool($vv) ? (int) $vv : $vv;
95 if ($vv !== null) {
96 $qs .= '=' . $encoder((string) $vv);
97 }
98 $qs .= '&';
99 }
100 }
101 }
102 return $qs ? (string) \substr($qs, 0, -1) : '';
103 }
104 }
105